質問

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.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top