unhandledException

处理未捕获的异常是每个应用程序起码有的功能,C#在AppDomain提供了UnhandledException 事件来接收未捕获到的异常的通知。常见的应用如下:

1 static void Main(string[] args)
2 {
3    AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
4 }
5 static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
6 {
7    Exception error = (Exception)e.ExceptionObject;
8    Console.WriteLine("MyHandler caught : " + error.Message);
9 }
世界上最可怕事情是比我们优秀的人比我们还努力
原文地址:https://www.cnblogs.com/AlexOneBlogs/p/7398438.html