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());
        }
原文地址:https://www.cnblogs.com/LcVong/p/12469278.html