就是尽量/左右整个C#程序捕获可能吗? [英] Is try/catch around whole C# program possible?
问题描述
一个C#程序被调用的:
A C# program is invoked by:
Application.Run (new formClass ());
我想提出一个try / catch周围的整个事情要捕获任何未捕获的异常。当我把它解决此运行方式,异常没有被卡住;控制只有当程序未捕获的异常终止后返回这里。
I'd like to put a try/catch around the whole thing to trap any uncaught exceptions. When I put it around this Run method, exceptions are not caught; control only returns here when the program terminates after an uncaught exception.
我在哪里可以把try / catch语句覆盖整个程序? !谢谢
Where can I put try/catch to cover the whole program? Thanks!
推荐答案
要赶上Windows窗体的未处理的异常钩行动的
的 AppDomain.UnhandledException
和的 Application.ThreadException
事件。
To catch Windows Form's unhandled exceptions hook-up the
AppDomain.UnhandledException
and Application.ThreadException
events.
有趣的:在托管应用程序一意外的错误>
Of interest: Unexpected Errors in Managed Applications
这篇关于就是尽量/左右整个C#程序捕获可能吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!