Stackoverflow gave me an idea that worked out well in my case. I added code to the WindowsFormsApplicationBase.Startup event handler that- if DEBUG is defined and the debugger is attached- adds a handler for the AppDomain.UnhandledException event. (The conditional logic might be overly defensive but I can't take any chances with this mature, stable application.) When the AppDomain.UnhandledException event handler fires, it merely calls the WindowsFormsApplicationBase.UnhandledException event handler, where I've set a breakpoint.
Private Sub AppDomainUnhandledException(ByVal sender As Object, ByVal args As UnhandledExceptionEventArgs) Dim ex As Exception = DirectCast(args.ExceptionObject, Exception) Dim newArgs As New Microsoft.VisualBasic.ApplicationServices.UnhandledExceptionEventArgs(False, ex) MyApplication_UnhandledException(sender, newArgs) End Sub
Now I can step through my changes. Yippee!