我有一个客户端和服务器方案,其中一个服务安装在客户端上,另一个服务在服务器上。当这些安装在不同的机器上时,我没有任何问题。但是,我希望能够在同一台计算机上同时安装客户端服务和服务器服务。我可以将它们设置为使用不同的端口,但是我希望使用单个端口来完成此操作。如果两个应用程序使用不同的端点地址,两个应用程序可以共享相同的WCF NetTcpBinding端口吗?
我已启用并启动Net.Tcp端口共享服务Windows服务。我首先启动服务器服务。当我尝试启动客户服务,我在执行serviceHost.Open()出现以下情况例外:
The TransportManager failed to listen on the supplied URI using the NetTcpPortSharing service: the URI is already registered with the service.
下面是源代码。服务器和客户端使用不同的端点地址如下:
Server服务:
ServiceHost serviceHost = new ServiceHost(typeof(ServerService),
new Uri("net.tcp://localhost:50000");
NetTcpBinding binding = new NetTcpBinding();
serviceHost.AddServiceEndpoint(typeof(IServerService),
binding, "ServerService");
serviceHost.Open();
客户服务:
ServiceHost serviceHost = new ServiceHost(typeof(ClientService),
new Uri("net.tcp://localhost:50000");
NetTcpBinding binding = new NetTcpBinding();
serviceHost.AddServiceEndpoint(typeof(IClientService),
binding, "ClientService");
serviceHost.Open();
此页面不再可用,请在此分享您的解决方案? – cguedel 2013-09-27 21:51:44