2

I have some problems with WCF service instances.

ChannelFactory<IMyInterface> factory = new ChannelFactory<IMyInterface>(new NetTcpBinding(), new EndpointAddress("net.tcp://localhost:8000"));

IMyInterface iFirst = firstFactory.CreateChannel();
iFirst.firstMethod();

IMyInterface iSecond = firstFactory.CreateChannel();
iSecond.secondMethod();

It works fine but creates two instances of service class on server side. InstanceContextMode is set to InstanceContextMode.PerSession and I would like to keep it that way. I found this article:

http://msdn.microsoft.com/en-us/magazine/cc163590.aspx#S4

In section Duplicating a Proxy is Figure 5 Duplicating a Proxy. I seems to be perfect solution but IClientChannel no longer contains ResolveInstance() method. Is there any other way to create two channels connected to one service instance without setting InstanceContextMode to InstanceContextMode.Single?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
user1094613
  • 71
  • 1
  • 4
  • May be you want to finish your first question posted here http://stackoverflow.com/questions/8504059/wcf-multiple-channels-for-one-serivce-instance – Surjit Samra Dec 14 '11 at 17:19

1 Answers1

1

The IClientChannel.ResolveInstance method has been replaced with a new extensibility point, the System.ServiceModel.Dispatcher.IInstanceContextProvider interface.

The change is described here: http://blogs.msdn.com/b/mahjayar/archive/2006/07/08/660176.aspx - perhaps you can implement that interface to get what you want to acheive.

kmp
  • 10,535
  • 11
  • 75
  • 125