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

本文提供两种方法来禁用JIT调试,从而避免在.NET程序出现未处理异常时弹出对话框,提升用户体验。第一种方法是通过配置文件(machine.config或application.exe.config)设置jitDebugging值为false;第二种方法则是编辑注册表以完全禁用JIT调试功能。
 

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

 

在使用 Homebrew 安装 PHP 时,可能会遇到类似 `unrecognized options: --disable-pcre-jit` 的错误。这通常出现在尝试通过自定义编译选项安装特定版本的 PHP 时,特别是在使用某些旧版本的 PHP Formula 或手动修改了安装脚本的情况下。 PHP 在其构建过程中依赖于 PCRE(Perl Compatible Regular Expressions)库来处理正则表达式功能。从 PHP 7.3 开始,PCRE 库被更新为使用 PCRE2,而 `--disable-pcre-jit` 是一个用于控制是否启用 PCRE JITJust-In-Time 编译)优化的配置选项。如果使用的 Homebrew Formula 版本较旧,或者对 PHP 编译参数进行了定制,可能会导致该选项不再有效,从而引发错误[^1]。 解决这一问题的方法包括: - **更新 Homebrew 及相关仓库**:确保 `homebrew/core` 和 `homebrew/php` 等仓库是最新的,可以通过以下命令更新: ```bash brew update brew upgrade ``` - **使用官方维护的 Formula**:避免手动修改 Formula 文件中的编译参数,除非明确知道其作用。推荐使用默认的安装方式,例如: ```bash brew install php@8.1 ``` - **检查 Formula 中的编译参数**:如果确实需要自定义安装,应确认所使用的 `configure` 参数是否与当前 PHP 版本兼容。部分旧版本的 Formula 可能仍保留了已废弃的选项,如 `--disable-pcre-jit`,此时应将其移除或替换为对应的最新参数[^1]。 - **使用国内镜像加速安装**:如果因网络问题导致无法正常更新 Formula 或下载依赖包,可以考虑使用国内镜像源,例如 Gitee 提供的 Homebrew 镜像脚本: ```bash /bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)" ``` 通过上述方法,可以有效避免由于过时或不兼容的编译选项导致的安装失败问题。 ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值