What should I pass to duplex WCF client instance context

2.5k views Asked by At

Here is a generated proxy for my duplex WCF service:

 public partial class MyWcfServiceClient : System.ServiceModel.DuplexClientBase<Ifa.WcfClients.ServiceReference1.IMyWcfService>, Ifa.WcfClients.ServiceReference1.IMyWcfService {

    public MyWcfServiceClient(System.ServiceModel.InstanceContext callbackInstance) : 
            base(callbackInstance) {
    }            
      .
      .
      .
}

I want to inherit from this class and build a new class like this:

public class WcfClientBase : MyWcfServiceClient
{
    public WcfClientBase() : base(???)
    {
    }

    somemethod1(){....}
    somemethod2(){....}    
}

My problem is that the base class needs an argument of InstanceContext. What should I pass as this argument?

1

There are 1 answers

3
Vivek On BEST ANSWER

It's a duplex setup right? Meaning the server communicates results back via callbacks.

So the client needs to specify the class which has these callback methods - which will get invoked on replies from server.

You need to write a class implementing the callback interface (it'll be part of your service contract) and then pass an object of this class to the InstanceContext.