简体   繁体   中英

What should I pass to duplex WCF client instance context

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM