我正在尝试在Windows服务中托管的WCF与我的服务GUI之间进行通信。问题是当我尝试执行OperationContract方法时,我遇到了以下错误:
"The ChannelDispatcher at 'net.tcp://localhost:7771/MyService' with contract(s) '"IContract"' is unable to open its 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>
通过netstat检查,端口7771处于监听状态,并且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)
在异常信息中有一个内部异常(但不在Exception.InnerExeption下,而是在Exception.Detail.InnerExeption下 - ToString()方法不显示它)
已经为URI“net.tcp://localhost:7771/MyService”注册了一个注册表项。
但我的服务只在app.config文件中指定了这个URI,在整个解决方案中,此URI只出现一次于服务器和客户端各一次。