简体   繁体   English

WCF:OneWay OperationContract上的异常处理

[英]WCF: Exception handling on OneWay OperationContract

I am having a WCF duplex service with Silverlight client and .NET 3.5 WCF service. 我正在使用Silverlight客户端和.NET 3.5 WCF服务的WCF双工服务。

The scenario I have is: during the duplex push OneWay operation from server to client if an exception happens in client notification handler the channel gets silently faulted so any further duplex calls from server timeout and fail. 我的方案是:在双工推送OneWay操作从服务器到客户端如果在客户端通知处理程序中发生异常,则通道会出现静默故障,因此任何进一步的双工调用都会从服务器超时并失败。 (As explained here One-Way Operations and Exceptions ) (如此处所解释的单向操作和例外

My question(s): 我的问题:

  1. Can I just decorate with FaultContract a OneWay OperationContract , wrap the exception on client and prevent faulting of the channel? 我可以使用FaultContract装饰OneWay OperationContract ,在客户端包装异常并防止通道错误吗?
  2. if not, what would be some other way to catch the exception which occurred on the client during the duplex push from server? 如果没有,在从服务器双工推送期间捕获客户端上发生的异常会有什么其他方法?

When you use OneWay OperationContract , the receiver should not reply nor the sender of the request should expect one. 当您使用OneWay OperationContract ,接收方不应该回复,也不应该请求发送方。

  1. You can't. 你不能。
  2. Your best bet is you can create another OneWay OperationContract between client and the service so that the service can send the fault to the client. 您最好的选择是在客户端和服务之间创建另一个OneWay OperationContract ,以便服务可以将故障发送给客户端。

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

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