捕获当前线程中的所有异常 [英] Catching all exceptions in current thread

查看:86
本文介绍了捕获当前线程中的所有异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的Web应用程序中,我有一种单向异步WCF服务.在此服务中,我想捕获所有异常,就像在global.asax Application_Error中所做的一样.我已尝试处理以下事件:

In my web application I have a one way async WCF service. In this service I want to catch all exceptions like I do in global.asax Application_Error. I''ve tried to handle these events:

AppDomain.CurrentDomain.UnhandledException += (s,e) => { //some logic };
AppDomain.CurrentDomain.FirstChanceException += (s,e) => { //some logic };


甚至尝试过:

//这是用于Win Forms应用程序的


even tried:

//this one is for Win Forms Application

Application.ThreadException += (s,e) => { //some logic };




//这是针对Web应用程序的


and

//this one is for Web Application

HttpContext.Current.ApplicationInstance.Error += (s,e) => { //some logic };


但是这些处理程序都没有到达.

有什么想法,我还能尝试什么?


But none of these handlers are reached.

Any ideas, what else can I try?

推荐答案

尝试

WCF中的异常处理 [ http://blog.arogldarthu.nl/archives/12-Wcf-Exception- Shielding-Unexpected-FaultContracts.html [ ^ ]
Try

Exception Handling in WCF[^]

http://blog.arogldarthu.nl/archives/12-Wcf-Exception-Shielding-Unexpected-FaultContracts.html[^]


这篇关于捕获当前线程中的所有异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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