且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在ASP.NET中如何处理未处理的异常?

更新时间:2023-02-15 12:51:53

调试 - >异常,检查公共语言运行时异常的'Thrown'列(至少)。检查'Thrown'为您感兴趣的其他异常。

Under Debug->Exceptions, check the 'Thrown' column of Common Language Runtime Exceptions (at a minimum). Check 'Thrown' for other Exceptions you're interested in.

现在,如果调试器被连接(主动调试或附加到进程),您的ASP.NET应用程序将会在CLR异常(或您选择的任何其他异常)中断。

Now, if the debugger is attached (active debug or 'Attach to Process'), your ASP.NET app will break on a CLR Exception (or any other Exception you've selected).

如果您想在未处理的例外中仅打破 在Debug-> Exceptions下,取消选中所有异常类型上的Throwwn,并确保对您感兴趣的异常检查User-unhandled。

If you want to break only on unhandled Exceptions, under Debug->Exceptions, uncheck 'Thrown' on all Exception types and make sure 'User-unhandled' is checked for the Exceptions you're interested in.

异常接口http://scatterbright.com/debug-exceptions.png

然后,如果调试器被连接,你的ASP.NET应用程序会破坏你所选择的每个用户未处理的异常,而不管运行时最终会捕获异常的事实。示例:

Then, if the debugger is attached, your ASP.NET app will break on every User-unhandled Exception you've selected regardless of the fact the runtime will eventually catch the Exception. Sample:

调试器打破用户未处理的异常http://scatterbright.com/ debugcatchingunhandledex.png