简体   繁体   English

WCF服务-捕获全局异常

[英]WCF Service - catch global exceptions

Im using enterprise library in order to handle exceptions, I need to know how can I catch everysingle exception without putting try/catch statements everywhere. 我使用企业库来处理异常,我需要知道如何在不将try / catch语句放到任何地方的情况下捕获每个异常。

For example, im using caliburn micro on the client side which has the method : OnUnhandledException. 例如,即时通讯在客户端使用caliburn micro,该客户端具有以下方法:OnUnhandledException。

For a WCF Service you can create an IErrorHandler implementation and register it. 对于WCF服务,您可以创建IErrorHandler实现并进行注册。 It will receive and be able to act on all exceptions created by the service implementation before returning to the client. 在返回客户端之前,它将接收并能够对服务实现创建的所有异常采取行动。

另一种可能性是创建派生IOperationInvoker的自定义类,并在try / catch块中包装方法调用。

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

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