2011-12-14 29 views
2

我在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

+0

可能是你想完成你在這裏發佈的第一個問題http://stackoverflow.com/questions/8504059/wcf-multiple-channels-for-one-serivce-instance – 2011-12-14 17:19:45

回答

相關問題