[Mono-dev] WCF: Contracts with Interface hierarchy

KarstenF fourmont at gmx.de
Sun Sep 26 06:20:28 EDT 2010


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:

interface ServiceInterface : Foo

interface Foo : Bar
    [OperationContract] void Foo();

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:
returns 4 interfaces: bar is yielded twice to some recursion logic glitch.
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
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!

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.

More information about the Mono-devel-list mailing list