[Mono-dev] WCF: Contracts with Interface hierarchy

Rafael Teixeira monoman at gmail.com
Mon Sep 27 14:41:36 EDT 2010


Please fill a bug report.

Thanks,

Rafael "Monoman" Teixeira
---------------------------------------
"We live in a world operated by science and technology. We have also
arranged things so that almost no one understands science and
technology. This is a prescription for disaster. We might get away
with it for a while, but sooner or later this combustible mixture of
ignorance and power is going to blow up in our faces."
-Carl Sagan



On Sun, Sep 26, 2010 at 7:20 AM, KarstenF <fourmont at gmx.de> wrote:
>
> Hi,
>
> I'm new to Mono and new to this list so let's hope my post doesn't contain
> too many newbie's errors...
>
> I've got a large WCF-heavy .NET project. With upcoming mono 2.8 I'd try to
> give it a shot and make it run on mono. Here's an issue I've found when
> using contract interfaces with a hierarchy. Consider this:
>
> [ServiceContract]
> interface ServiceInterface : Foo
> {
> }
>
> [ServiceContract]
> interface Foo : Bar
> {
>    [OperationContract] void Foo();
> }
>
> [ServiceContract]
> interface Bar {
>    [OperationContract] void FooBar();
> }
>
> class DummyService : ServiceInterface
> {
>    public void FooBar() { }
>
>    public void Foo() { }
>
>    public static ServiceHost Create() {
>        return new ServiceHost(typeof(DummyService)); // fine in MS, fails in Mono
> with "A contract cannot have two operations that have the identical names
> and different set of parameters"
>    }
> }
>
> What happens is this:
> 1.
> System.ServiceModel.Description.ContractDescriptionGenerator.GetAllInterfaceTypes(ServiceInterface)
> returns 4 interfaces: bar is yielded twice to some recursion logic glitch.
> 2.
> System.ServiceModel.Description.ContractDescriptionGenerator.GetServiceContractAttribute
> returns 3 service contracts: ServiceInterface, Foo and Bar. This is due to
> Foo and Bar needing the [ServiceContract] attribute:  According to Microsoft
> interfaces without that attribute are not allowed to have
> [OperationContract] methods.
>
> Ultimately both 1. and 2. result in method FooBar beeing added multiple time
> to
> System.ServiceModel.Description.ContractDescriptionGenerator.GetOrCreateOperation()
> This then throws an "cannot have two operations that have the identical
> names and different set of parameters".
> This is obviously wrong as the methods have the very same set of parameters.
> imho neither 1 nor 2 need fixes. It's rather GetOrCreateOperation which
> should check if the existing method in the contract has the same signature
> and if so then just ignore it. After all it's perfectly valid to have a
> method declared at different points in an interface hierarchy as long as the
> signature remains the same.
>
> I tried to create a patch myself but I'm having trouble to build
> System.ServiceModel.csproj of the mono-2-8 branch using monodevelop (or
> xbuild from mono-2-8p5 on windows): there are quite a files in the project
> that are not there (i think obsolete and moved to old code but I'm not sure)
> and I get lots of compiler errors. Any ideas what I do wrong?
>
> Shall I post a bug (Component: WCF?)
>
> Thank you for making mono such a great thing!
>
>  Karsten
> --
> View this message in context: http://mono.1490590.n4.nabble.com/WCF-Contracts-with-Interface-hierarchy-tp2714228p2714228.html
> Sent from the Mono - Dev mailing list archive at Nabble.com.
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list
>


More information about the Mono-devel-list mailing list