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);//捕获到的异常        }


        }

 

posted @ 2013-05-03 13:36  咸鱼公子  Views(1075)  Comments(0Edit  收藏  举报