4dots Software
CODE HELP BLOG
ExceptionHandlersHelper.AddUnhandledExceptionHandlers();
Now add the following class to your project :
class ExceptionHandlersHelper
{
public static void AddUnhandledExceptionHandlers()
{
// Define a handler for unhandled exceptions.
AppDomain.CurrentDomain.UnhandledException +=
new System.UnhandledExceptionEventHandler(myExceptionHandler);
Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(
myThreadExceptionHandler);
}
private static void myExceptionHandler(object sender, UnhandledExceptionEventArgs e)
{
Exception ex = (Exception)e.ExceptionObject;
MessageBox.Show(ex.ToString());
}
private static void myThreadExceptionHandler(object sender, System.Threading.ThreadExceptionEventArgs e)
{
Exception ex = (Exception)e.Exception;
MessageBox.Show(e.Exception.ToString());
}
}