【发布时间】:2012-01-20 11:04:42
【问题描述】:
我在使用 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 的情况下创建连接到一个服务实例的两个通道?
【问题讨论】:
-
也许你想完成你在这里发布的第一个问题stackoverflow.com/questions/8504059/…