我正在尝试在 Windows 服务中托管的 WCF 和我的服务 GUI 之间进行通信。问题是当我尝试执行我得到的 OperationContract 方法时
“'net.tcp://localhost:7771/MyService' 的 ChannelDispatcher 与合同 ''IContract'' 无法打开其 IChannelListener。”
我的 app.conf 看起来像这样:
<configuration>
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="netTcpBinding">
<security>
<transport protectionLevel="EncryptAndSign" />
</security>
</binding>
</netTcpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="MyServiceBehavior">
<serviceMetadata httpGetEnabled="true" httpGetUrl="http://localhost:7772/MyService" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="MyServiceBehavior"
name="MyService.Service">
<endpoint address="net.tcp://localhost:7771/MyService" binding="netTcpBinding"
bindingConfiguration="netTcpBinding" name="netTcp" contract="MyService.IContract" />
</service>
</services>
</system.serviceModel>
端口 7771 正在监听(使用 netstat 检查)并且 svcutil 能够为我生成配置。
任何建议,将不胜感激。
异常的堆栈跟踪
Server stack trace: at System.ServiceModel.Channels.ServiceChannel.ThrowIfFaultUnderstood(Message reply, MessageFault fault, String action, MessageVersion version, FaultConverter faultConverter) at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc) at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout) at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs) at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation) at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
有一个内部异常(但不在 Exeption.InnerExeption 下,而是在 Exeption.Detail.InnerExeption 下 - ToString() 方法没有显示)
URI 'net.tcp://localhost:7771/MyService' 的注册已经存在。
但是我的服务只在 app.config 文件中指定了这个 URI,没有其他地方。在整个解决方案中,此 URI 出现在服务器一次和客户端一次。