0

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?

Sentry
  • 4,102
  • 2
  • 30
  • 38
r.zarei
  • 1,261
  • 15
  • 35

1 Answers1

1

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.

Vivek
  • 2,103
  • 17
  • 26
  • yes it is. so if server calls client methods, does my methods declared in WcfClientBase are called? or the methods declared in callback class? – r.zarei Aug 30 '13 at 15:03
  • 1
    They will be the methods in the object you passed to InstanceContext, which would be the callback class. – Vivek Aug 30 '13 at 20:39
  • accodring to this, i can not create a subclass form duplex wcf client – r.zarei Aug 31 '13 at 10:32