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