Unused .NET Dialog Unhandled Exception

I am working on a .NET 4.0 Beta 1 application. When the application starts without a debugger and an unhandled exception is thrown, the application crashes, never opening the Unhandled Exception dialog box (the one that showed the stop code and the exception that was thrown).

I realize this behavior is desirable in production, but I'm currently trying to debug some nasty errors that happen when the debugger is not connected.

Is there a way to make this dialog appear when there is an unhandled exception?

thank

EDIT: This is a WPF application. Right now I'm listening for the UnhandledException event, but after the application finishes executing the handler, it will still crash. The dialogue made it possible to continue (one of the things that interest me is this).

+2


source to share


2 answers


If it's a winforms application, you can set up an error handler for the AppDomain to catch / handle any uncaught exceptions.



AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);

static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
  //deal with e.ExceptionObject for info
}

      

+2


source


Try attaching a handler to Application.ThreadException (for Windows Forms apps) and / or System.AppDomain.CurrentDomain.UnhandledException (for console apps).



0


source







All Articles