Unhandled exception

I wrote a utility that monitors Unhandled Exceptions, and then creates a minidump in case this happens.

Is there a way when the event fires, instead of having a standard message box displaying an unhandled exception, can I turn it off and display my information on it with various information?

Thank.

+3
source share
4 answers

Refer to the event Application.ThreadExceptionto display your own error messages.

You can intercept the event at the top of the main method as follows:

Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);

And then you need the Handler method:

static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
{
    MessageBox.Show(e.Exception.ToString());
}

: AppDomain.UnhandledException, ThreadException.

+2

, , . MessageBox .

+2

You can do it,

catch(Exception e)
{
throw new Exception("This is unhandled exception");
}
+1
source

Source: https://habr.com/ru/post/1776476/


All Articles