Click here to Skip to main content
15,881,709 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
The scenario is rather involved, but perhaps this stripped-down summary can be sufficient to get me pointed in the right direction.
I have a service that provides data to my application. WCF is used to provide the interaction between them. I also have a debug version of the service that I use to provide generated test data to the application. The debug version copies all of the WCF-related code and configuration data, reusing the DLLs from which the service is built. The service works and so does the WCF connection to it. The debug version starts to work, but fails to make the WCF connection, complaining that two methods in the same contract have the same name.
The basic architecture involved is:
C#
using System.ServiceModel;

namespace nsOne
{
    [ServiceContract]
    public interface IFoobarOne
    {
        [OperationContract] void FooOne(string str);
        [OperationContract] void BarOne(string str);
    }
}

namespace nsTwo
{
    [ServiceContract(/*...*/)]
    public interface IFoobarTwo : nsOne.IFoobarOne
    {
        [OperationContract] void FooTwo(int number);
        [OperationContract] string BarTwo();
    }

    public abstract class One<T> : nsOne.IFoobarOne
    {
        public virtual void FooOne(string str) { /*...*/ }
        public virtual void BarOne(string str) { /*...*/ }
    }

    public interface IOther { /*...*/ }

    [ServiceBehavior(/*...*/)]
    public class BeOne : One<IOther>, IFoobarTwo
    {
        public BeOne() { /*...*/ }

        public void FooTwo(int number) { /*...*/ }
        public string BarTwo() { /*...*/ return "me"; }
    }
}

namespace nsThree
{
    public class Something<T> where T: class, nsOne.IFoobarOne
    {
        protected T proxy;

        protected void DoSome()
        {
            proxy.FooOne("abc");
        }
    }

    public class SomethingMore : Something<nsTwo.IFoobarTwo>
    {
        private void DoMore()
        {
            DoSome();
            proxy.FooTwo(2);
        }
    }
}

namespace nsFour
{
    [ServiceBehavior(/*...*/)]
    public class BeOneToo : nsTwo.One<nsTwo.IOther>, nsTwo.IFoobarTwo
    {
        public BeOneToo(object param) { /*...*/ }

        public void FooTwo(int number) { /*...*/ }
        public string BarTwo() { /*...*/ return "you"; }
    }
}
In terms of this example, the Service constructs a BeOne object using:
C#
serviceHost = new ServiceHost(typeof(BeOne));
In the Application, a SomethingMore object successfully accesses and manipulates (via WCF) the BeOne object in the Service.
Namespaces nsOne, nsTwo, and nsThree are contained in the same VS solution.
Namespace nsFour hosts the debug version of the service. The DLLs for other namespaces are included by reference, but their projects are not in that VS solution. The WCF objects are created using:
C#
var objBeOneToo = new BeOneToo(this);
serviceHost = new ServiceHost(objBeOneToo);
When it runs, the object is successfully created, but ServiceHost construction throws an exception complaining that there are two contract methods named BarOne. If I look at the definitions of IFoobarOne and IFoobarTwo that IntelliSense derives from the DLL metadata, sure enough, both include a declaration for BarOne, yet only IFoobarOne contains a declaration for FooOne.
I'm baffled. Why does the IFoobarTwo DLL correctly point to IFoobarOne.FooOne, but not to IFoobarOne.BarOne? How do I correct it?

What I have tried:

Looked at Error: Cannot have two operations in the same contract with the same name[^], but it doesn't address this issue.
Posted
Updated 6-Sep-18 3:57am
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900