************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.
For example:
<configuration>
<system.windows.forms jitDebugging="true" />
</configuration>
When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.
.net程序排除不可预见的错误就会抛出上述错误,但是有时候上述错误不一定影响程序的正常运行,但是给用户看到这样的东西是不太好的,因此需要将其disable
方法如下
方法一:
To disable Just-In-Time debugging of a Windows Form
-
Set the jitDebugging value in the machine.config or application.exe.config file, located in the system.windows.forms section to true. For example:
-
In addition, Windows Forms created by using C++ must have the DebuggableAttribute set in a .config file or within their code. If you compile with /Zi and without /Og, the compiler sets this attribute for you. If you want to debug a non-optimized release build, however, you must set this yourself by adding the following line to your application's AssemblyInfo.cpp file:
For more information, see DebuggableAttribute.
方法二:
To disable Just-In-Time debugging by editing the registry
-
In the Start menu, click Run.
-
In the Run dialog box, type regedit, then click OK.
-
In the Registry Editor window, locate and delete the follow registry keys:
-
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AeDebug\Debugger
-
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\DbgManagedDebugger
-
-
If your computer is running a 64-bit operating system, delete the following registry keys also:
-
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows NT\CurrentVersion\AeDebug\Debugger
-
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\.NETFramework\DbgManagedDebugger
-
-
Take care not to accidentally delete or change any other registry keys.
-
Close the Registy Editor window.
参考信息
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!