Say I have a WCF maintenance contract like this
[ServiceContract(CallbackContract = typeof(ICallback1), SessionMode = SessionMode.Required)] public interface IService1 {
The service implementation has InstanceContextMode.Single for InstanceContextMode and ICallback1 - it's something like
public interface ICallback1 { [OperationContract] void Report(int someValue); }
Now on the client side, I can have a class that implements ICallback1, for example
class Callback1 : ICallback1 { public void Report(int someValue) {
and I create a customer service link like this
Service1Client serviceClient = new Service1Client(new InstanceContext(new CallBack1()));
which works great. Now the problem is that I have some clients that are not interested in a callback, so I decided that I did not need to implement a callback interface for such clients, so I tried this
Service1Client serviceClient = new Service1Client(null);
and
Service1Client serviceClient = new Service1Client(new InstanceContext(null));
both reported that parameter cannot be null . My question is how can I create a link to a service without passing a callback object if the client is not interested in the callback. The only requirement is that all clients must talk to the same service, but otherwise I can restructure the service. Any thoughts?
EDIT:
I also tried SessionMode = SessionMode.Allowed for ServiceContract instead of SessionMode.Required , but that didn't help either.
c # wcf duplex
Bala r
source share