[Mono-dev] WCF: Contracts with Interface hierarchy

Atsushi Eno atsushieno at veritas-vos-liberabit.com
Wed Sep 29 02:37:53 EDT 2010

  Hi Karsten,

Thanks for nice bug analysis. On building System.ServiceModel on 
MonoDevelop, you can just open "Makefile" to treat it as a class lib 
project (valid only in our mcs classes). The .csproj file there was from 
the past era, used by Mainsoft team. It is ambiguous like this time and 
I'd rather remove it unless the Mainsoft guys object.

We welcome your patch and/or bug report. I'll visit the issue once I 
have finished ongoing work.

Atsushi Eno

On 2010/09/26 19:20, KarstenF 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

More information about the Mono-devel-list mailing list