static void Main() { Application.ThreadException += new ThreadExceptionEventHandler(UIThreadException); Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); //Application.ApplicationExit += new EventHandler(Application_ApplicationExit); AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; SysConsole.Show(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()); }