wpf 通信对象 System.ServiceModel.Channels.ServiceChannel 无法用于通信,因为它处于 Faulted 状态
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15846997/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
The communication object, System.ServiceModel.Channels.ServiceChannel, cannot be used for communication because it is in the Faulted state
提问by Ranjita Das


error occur: "The communication object, System.ServiceModel.Channels.ServiceChannel, cannot be used for communication because it is in the Faulted state."
发生错误:“通信对象 System.ServiceModel.Channels.ServiceChannel 无法用于通信,因为它处于故障状态。”
that error occured due to app.config?
由于 app.config 发生该错误?
have any idea? Thanks
有什么想法吗?谢谢
回答by silentsanta
I was receiving this error, event though no first-chance exception was appearing on the server, and in my case it was because the response I was receiving included 200k of bytes (a pdf); and I hadn't set up the appropriate settings in my config file to allow large sizes, and appropriate timeouts:
我收到了这个错误,虽然服务器上没有出现第一次异常,但在我的情况下,这是因为我收到的响应包含 200k 字节(pdf);并且我没有在我的配置文件中设置适当的设置以允许大尺寸和适当的超时:
<netTcpBinding>
<binding name="NetTcpBinding_IExampleService" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" />
</binding>
</netTcpBinding>
It would have been nice if the error messages had been more specific.
如果错误消息更具体,那就太好了。
Obviously, my 2 gigabyte limit is not necessarily appropriate in your situation I would encourage readers to choose a value that is appropriate for your specific use case.
显然,我的 2 GB 限制不一定适合您的情况,我鼓励读者选择适合您特定用例的值。
回答by silentsanta
what can be the reason is that u use a service to get data from another program or whatever. for example if u use a technicService version 1.2 ( see web.config) and and for example a billingService version 1.3( see web.config) now it can happen that your billing service corresponds with technicService 1.3 instead of 1.2 then you olso get this error
可能的原因是您使用服务从另一个程序或其他程序获取数据。例如,如果您使用 technicService 1.2 版(请参阅 web.config)和例如 billingService 1.3 版(请参阅 web.config),现在您的账单服务可能与 technicService 1.3 而不是 1.2 对应,那么您也会收到此错误
回答by Pablote
That usually happens when you get an unhandled exception either in the server or the client. That client you have is not good anymore and you need to create a new one.
当您在服务器或客户端中遇到未处理的异常时,通常会发生这种情况。您拥有的那个客户不再好,您需要创建一个新客户。
In case the error happened on the server side, you should be using fault exceptions (they don't fault the channel). You can also subscribe to thisevent to know exactly when it happened.
如果错误发生在服务器端,您应该使用故障异常(它们不会对通道造成故障)。您还可以订阅此事件以确切了解它何时发生。

