disable just-in-time (JIT) debugging的两个方法

 

************** 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

  1. Set the jitDebugging value in the machine.config or application.exe.config file, located in the system.windows.forms section to true. For example:

    <configuration>
        <system.windows.forms jitDebugging="false" />
    </configuration>
    
  2. 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:

    [assembly:System::Diagnostics::DebuggableAttribute(false, false)]; 
    

    For more information, see DebuggableAttribute.

 

方法二:

To disable Just-In-Time debugging by editing the registry

  1. In the Start menu, click Run.

  2. In the Run dialog box, type regedit, then click OK.

  3. 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

  4. 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

  5. Take care not to accidentally delete or change any other registry keys.

  6. 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!

 

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值