我对 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
?