WCF异常处理策略 [英] WCF Exception Handling Strategies

查看:115
本文介绍了WCF异常处理策略的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在开发WCF中的代理,作为运行我们的定制客户端应用程序的一些手持设备的通信手段。我很好奇人们使用什么错误处理策略,因为我宁可在try / catch中包装每个代理调用。

We are developing a proxy in WCF that will serve as a means of communication for some handhelds running our custom client application. I am curious what error handling strategies people use as I would rather not wrap EVERY proxy call in try/catch.

当我开发ASP .NET时,我不会占用大部分例外,我利用Global asax中的Application_Error,然后可以记录异常,发送电子邮件,并将用户重定向到自定义错误着陆页。我在WCF中寻找的是类似的,除了它允许我从中央位置将一般的故障传递给客户。

When I develop ASP .NET I dont catch the majority of exceptions, I leverage Application_Error in Global asax which can then log the exception, send an email, and redirect the user to a custom error landing page. What I am looking for in WCF is similar to this, except that it would allow me to pass a general faultreason to the client from a central location.

基本上我很好奇人们如何集中在WCF应用程序中的异常处理。

Basically I am curious how people centralize their exception handling in WCF apps.

谢谢

推荐答案

您可能会在这里找到 IErrorHandler 界面。 。我们一直在使用这个功能来做几乎所提到的 - 集中式异常记录和提供广泛的故障原因,而无需用大量的try / catch来丢弃代码来尝试在本地处理问题。

You might find the IErrorHandler interface useful here. We've been using this to do pretty much what you mention - centralised exception logging and providing generalised fault reasons without having to litter the code with numerous try/catches to try and deal with the problem locally.

这篇关于WCF异常处理策略的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆