C#捕获异常崩溃时

 Application.EnableVisualStyles();
            Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
            ;
            Application.SetCompatibleTextRenderingDefault(false);

            Application.Run(new main());
        }

        static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
        {
            MessageBox.Show("程序需要重新启动:" + e.Exception.Message);//捕获到的异常        }


        }
原文地址:https://www.cnblogs.com/qq4004229/p/3056480.html