OnUnhandledException is not called

Topics: CAB & Smart Client Software Factory
Jun 21, 2006 at 5:25 AM
originally posted by: Sergey

I have class:


class Program: ApplicationContextApplication<WorkItem, ApplicationContext>
{
STAThread
static void Main()
{
new Program().Run();
}


public override void OnUnhandledException(object sender, UnhandledExceptionEventArgs e)
{
//...
}
}

But method OnUnhandledException isn't called when unhandled exception occurs. What am I doing wrong? I have tried to start this code not from VS.NET 2005 debugger - the same result.
Jun 21, 2006 at 10:28 AM
originally posted by: austinlamb

Before your new Program().Run(), you need to add:
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(OnUnhandledException);