C#执行文件抛出异常方法

在程序入口添加如下代码:

 AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);

在后面添加方法:

        private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            Console.WriteLine(e.ExceptionObject.ToString());
            MessageBox.Show(e.ExceptionObject.ToString());
        }

 

posted @ 2020-03-12 14:53  LcVong  Views(49)  Comments(0Edit  收藏  举报