A day may come when you want to turn off the Debug dialog that appears when a .NET program has an unhandled exception.
Option 1: Registry key from Enabling JIT Debugging
For an application that includes managed code, the common language runtime will present a similar dialog to JIT-attach a debugger. The registry key that controls this option is called HKEY_LOCAL_MACHINE\Software\Microsoft\.NETFramework\DbgJITDebugLaunchSetting.
- If value = 0, prompt the user by means of a message box. The choices are:
- Continue. This results in a stack dump and process termination.
- Attach a debugger. In this case, the runtime spawns the debugger listed in the DbgManagedDebugger registry key. If none, control is returned, and the process is terminated.
- If value = 1, simply return control. This results in a stack dump, after which the process is terminated. (No more dialog)
- If value = 2, spawn the debugger listed in the DbgManagedDebugger registry key.
Option 2: If you want to disable the JIT debug dialog, but still want an error dialog:
Visual Studio.NET|Tools|Options|Debugging|Just-In-Time and deselect "Common Language Runtime" and now you’ll get an OK/Cancel dialog instead of the select a Debugger Dialog. Note: The registry entry from Option 1 above will need to be 0 for the dialog to show up.
Thanks to Eric Deslauriers of Corillian QA for these tips!