我在WCF服务实例中遇到了一些问题。WCF如何创建连接到相同服务实例的两个通道
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();
它工作正常,但在服务器端创建服务类的两个实例。 InstanceContextMode
设置为InstanceContextMode.PerSession
,我想保留这种方式。我发现这篇文章:
http://msdn.microsoft.com/en-us/magazine/cc163590.aspx#S4
在第Duplicating a Proxy
是图5复制代理。我似乎是完美的解决方案,但IClientChannel
不再包含ResolveInstance()
方法。有没有其他方法可以创建连接到一个服务实例的两个通道,而无需将InstanceContextMode
设置为InstanceContextMode.Single
?
可能是你想完成你在这里发布的第一个问题http://stackoverflow.com/questions/8504059/wcf-multiple-channels-for-one-serivce-instance – 2011-12-14 17:19:45