简单的方法来捕捉C#.NET所有未处理的异常 [英] Easy way to catch all unhandled exceptions in C#.NET

查看:165
本文介绍了简单的方法来捕捉C#.NET所有未处理的异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有建于C#.NET这往往会产生SQL的一个相当稳定的数据流从不同的用户控制超时一个网站,我想轻松地弹出一些code捕捉所有未处理的异常,并将它们发送的东西,可以登录他们并显示一个友好的信息给用户。

I have a website built in C#.NET that tends to produce a fairly steady stream of SQL timeouts from various user controls and I want to easily pop some code in to catch all unhandled exceptions and send them to something that can log them and display a friendly message to the user.

如何通过最少的精力,捕捉所有未处理的异常?

How do I, through minimal effort, catch all unhandled exceptions?

这个问题似乎是说这是不可能的,但也不至于道理给我(和它的有关.NET 1.1的Windows应用程序):

this question seems to say it's impossible, but that doesn't make sense to me (and it's about .NET 1.1 in windows apps):

推荐答案

所有未处理的异常通过的Application_Error Global.asax中终于过去了。因此,给予一般例外消息或做伐木作业,请参阅Application_Error.

All unhandled exceptions finally passed through Application_Error in global.asax. So, to give general exception message or do logging operations, see Application_Error.

这篇关于简单的方法来捕捉C#.NET所有未处理的异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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