Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [SecurityPermission(SecurityAction.Demand, Flags = SecurityPermissionFlag.ControlAppDomain)]
- [STAThread]
- static void Main(string[] args)
- {
- Application.EnableVisualStyles();
- Application.SetCompatibleTextRenderingDefault(false);
- if (!System.Diagnostics.Debugger.IsAttached)
- {
- AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
- Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException, true);
- Application.ThreadException += new ThreadExceptionEventHandler(Application_ThreadException);
- }
- //...
- static void Application_ThreadException(object sender, ThreadExceptionEventArgs e)
- {
- CurrentDomain_UnhandledException(sender, new UnhandledExceptionEventArgs(e.Exception, false));
- }
- static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
- {
- UnhandledExceptionForm uef = new UnhandledExceptionForm(e.ExceptionObject as Exception);
- uef.ShowDialog();
- }
- // UnhandledExceptionForm will close the application if needed
Advertisement
Add Comment
Please, Sign In to add comment