简体   繁体   English

如何解决:WCF应用程序停止通过命名管道接收数据?

[英]how to troubleshoot: wcf application stops receive data via named pipe?

I have UI WPF application that displays data received from WCF named pipe. 我有UI WPF应用程序,该应用程序显示从WCF命名管道接收的数据。 Aftwer a while (~30 minutes) data is frozen (but after restart everything ok). 稍后(约30分钟),数据将冻结(但重新启动后一切正常)。 No errors is displayed. 没有错误显示。 UI is responsible. 用户界面负责。 How to resolve the issue? 该如何解决? Probably I should surrond entire application with "try/catch" and display any exceptions in messagebox? 可能我应该使用“ try / catch”替代整个应用程序,并在消息框中显示任何异常?

By default, wcf is configured for short lived sessions. 默认情况下,为短时会话配置了wcf。 You have to set the ReceiveTimeout of your NetNamedPipeBinding to TimeSpan.MaxValue for this behaviour to disapear. 您必须将NetNamedPipeBinding的ReceiveTimeout设置为TimeSpan.MaxValue,此行为才会消失。
This should solve the issue, anyway it is a good idea to add a handler to your channel's Faulted, Closed, ... events to know what is happening. 这应该可以解决问题,无论如何,最好将处理程序添加到通道的Faulted,Closed等事件中,以了解发生了什么。 (you have to cast your channel to an ICommunicationObject). (您必须将频道转换为ICommunicationObject)。 Because if anything goes wrong in wcf, your only solution is to create a new channel (it's not possible to go from Faulted or Closed state back to Open). 因为如果wcf中发生任何问题,您唯一的解决方案就是创建一个新通道(不可能从“故障”或“关闭”状态返回到“打开”)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM