Reputation: 5203
We subscribed unhandled thread exceptions and unhandled exceptions as given below
public partial class ICEView : Form
{
public ICEView()
{
InitializeComponent();
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(OnUnhandledException);
Application.ThreadException += new ThreadExceptionEventHandler(OnThreadException);
}
}
Sometimes the application crashes without entering the exception handlers showing an error message as in the link given below. But the error message we got does not have the "Debug" button. What could be the reason for showing the message box.
http://www.computerhope.com/issues/pictures/winerror.jpg
Upvotes: 0
Views: 290
Reputation: 3253
Try adding the exception handlers in the Main
method in Program.cs before your form or try adding the exception handlers before the InitializeComponent
method.
[STAThread]
static void Main()
{
Application.ThreadException += new ThreadExceptionEventHandler(OnThreadException);
Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(OnUnhandledException);
Application.Run(new ICEView());
}
Upvotes: 2