就是尽量/左右整个C#程序捕获可能吗? [英] Is try/catch around whole C# program possible?

查看:130
本文介绍了就是尽量/左右整个C#程序捕获可能吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一个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屋!

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