I\'m maintaining a .NET 1.1 application and one of the things I\'ve been tasked with is making sure the user doesn\'t see any unfriendly error notifications.
I\'ve a
Unhandled exception behavior in a .NET 1.x Windows Forms application depends on:
The default behavior of unhandled exceptions is:
The points of contact for an unhandled exception are:
The Windows Form built-in exception handling does the following by default:
You can disable the latter behavior by setting jitDebugging = true in App.Config
. But remember that this may be your last chance to stop app termination. So the next step to catch an unhandled exception is registering for event Application.ThreadException, e.g.:
Application.ThreadException += new
Threading.ThreadExceptionHandler(CatchFormsExceptions);
Note the registry setting DbgJitDebugLaunchSetting under HKEY_LOCAL_MACHINE\Software.NetFramework. This has one of three values of which I'm aware:
In Visual Studio, go to menu Tools → Options → Debugging → JIT to set this key to 0 or 2. But a value of 1 is usually best on an end-user's machine. Note that this registry key is acted on before the CLR unhandled exception event.
This last event is your last chance to log an unhandled exception. It's triggered before your Finally blocks have executed. You can intercept this event as follows:
AppDomain.CurrentDomain.UnhandledException += new
System.UnhandledExceptionEventHandler(CatchClrExceptions);