I tried two ways of catching unexpected unhandled exceptions:
static void Main()
{
AppDomain.CurrentDomain.UnhandledException +=
new UnhandledExceptionEventHandler(ErrorHandler.HandleException);
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
try
{
Application.Run(new OCR());
}
catch (Exception ex)
{
ErrorWindow errorWindow = new ErrorWindow(ex);
errorWindow.ShowDialog();
Application.Exit();
}
}
When i execute the application using visual studio, everything works fine. if i use exe file in the bin\Debug folder, the exceptions are not handled. Application behaves as if catch block wasn't there. I'm clueless what's going on. any ideas?
edit: exceptio nis not thron in Load