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

查看:18
本文介绍了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 接口在这里很有用.我们一直在使用它来完成您提到的几乎所有事情 - 集中式异常日志记录并提供通用的故障原因,而不必在代码中放置大量尝试/捕获来尝试在本地处理问题.

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天全站免登陆