WCF多个绑定

当我尝试多个终点时,我收到以下错误..

System.ServiceModel.AddressAlreadyInUseException: The TransportManager failed to listen on the supplied URI using the NetTcpPortSharing service: the service failed to listen. at System.ServiceModel.Channels.SharedConnectionListener.SharedListenerProxy.Register() at System.ServiceModel.Channels.SharedConnectionListener.SharedListenerProxy.Open(Boolean isReconnecting) at System.ServiceModel.Channels.SharedConnectionListener.StartListen(Boolean isReconnecting) at System.ServiceModel.Channels.SharedConnectionListener..ctor(BaseUriWithWildcard baseAddress, Int32 queueId, Guid token, OnDuplicatedViaDelegate onDuplicatedViaCallback) at System.ServiceModel.Channels.SharedTcpTransportManager.OnOpenInternal(Int32 queueId, Guid token) at System.ServiceModel.Channels.SharedTcpTransportManager.OnOpen() at System.ServiceModel.Channels.TransportManager.Open(TransportChannelListener channelListener) at System.ServiceModel.Channels.TransportManagerContainer.Open(SelectTransportManagersCallback selectTransportManagerCallback) at System.ServiceModel.Channels.TransportChannelListener.OnOpen(TimeSpan timeout) at System.ServiceModel.Channels.ConnectionOrientedTransportChannelListener.OnOpen(TimeSpan timeout) at System.ServiceModel.Channels.TcpChannelListener`2.OnOpen(TimeSpan timeout) at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) at System.ServiceModel.Channels.ReliableChannelListenerBase`1.OnOpen(TimeSpan timeout) at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) at System.ServiceModel.Dispatcher.ChannelDispatcher.OnOpen(TimeSpan timeout) at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) at System.ServiceModel.ServiceHostBase.OnOpen(TimeSpan timeout) at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) at System.ServiceModel.Channels.CommunicationObject.Open() at Microsoft.Tools.SvcHost.ServiceHostHelper.OpenService(ServiceInfo info) 

这是我的App.Config内容

                                                

如果有人可以指导我错在哪里,那就太好了。

在App.Config和Windows Service中都启用了Net TCP端口共享服务。这是我可以检查的。

可能是您使用相同的端口进行HTTP和TCP绑定。 尝试将TCP绑定上的端口更改为8732或8731以外的任何端口。

您不能在两个不同的绑定之间共享相同的确切端口,这两个绑定基于您上面发布的配置,您当前正在执行此操作。 您需要将wsHttp绑定放在与net.tcp绑定不同的端口上。 net.tcp端口共享的目的是允许多个进程为多个net.tcp绑定使用相同的端口…不跨多个不同的绑定和协议共享单个端口。

要成功利用WCF net.tcp端口共享,您需要启动“Net.Tcp端口共享服务”(请注意,它明确指出名称中的Net.Tcp)。 您可能还希望将其设置为自动启动,因此如果重新启动,则不必继续启动它。 启动端口共享Windows服务后,您可以在同一进程中,在同一物理计算机上跨多个进程共享任何net.tcp绑定的单个端口。 需要共享端口的每个net.tcp绑定都需要将portSharingEnabled属性设置为true。 如果您执行上述操作,那么您应该能够在任何进程中为任何启用了端口共享的net.tcp端点重用相同的端口。

这将不允许您与任何wsHttp绑定,basicHttp绑定,任何MSMQ绑定或任何第三方绑定共享相同的端口。 这是一个特定于WCF附带的netTcpBinding的function。

供参考: http : //msdn.microsoft.com/en-us/library/ms734772.aspx

我建议您启用跟踪 ,以便更好地了解问题。 在显示错误消息时,WCF可能是ab * tch。

这可能是tcp绑定/配置的问题,而不是多个绑定的问题。

要测试它,请删除对http绑定的引用,并查看tcp绑定是否可以单独工作。