OnUnhandledException is not called

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

I have class:

class Program: ApplicationContextApplication<WorkItem, ApplicationContext>
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 11:28 AM
originally posted by: austinlamb

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