Compartilhar via


Enabling JIT-attach Debugging 

JIT-attach debugging is the phrase used to describe attaching a debugger to an executable image that throws an uncaught exception. In unmanaged code, it is what happens when you see a message box that invites you to:

  • Click OK to terminate the program

  • Click CANCEL to debug the program

If you click CANCEL, a debugger is started and attached to the process. The registry key that controls this is called HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\Current Version\AeDebug.

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. This only applies to processes that are interactive with the desktop; services and other noninteractive processes will terminate.

    In the .NET Framework versions 1.0 and 1.1, or the .NET Framework version 2.0 on Windows 98 and Windows Me, the message box choices are:

    • Continue. This results in a stack dump to the console and process termination.

    • Attach a debugger. In this case, the runtime spawns the debugger listed in the DbgManagedDebugger registry key. If none is found, the process is terminated.

    In the .NET Framework version 2.0 on platforms other than Windows 98 and Windows Me, the choices are:

    • Send. An error report is sent to Microsoft, followed by process termination. See http://winqual.microsoft.com for information on how to retrieve these reports.

    • Don't Send. This results in a stack dump to the console and process termination.

    • Debug. The runtime spawns the debugger listed in the DbgManagedDebugger registry key. If none is found, the process is terminated.

  • If value = 1, simply return control. This results in a stack dump, after which the process is terminated.

  • If value = 2, spawn the debugger listed in the DbgManagedDebugger registry key.

  • If value = 16, in the .NET Framework version 2.0 only, the runtime presents the message box described above for processes that are interactive with the desktop. For processes that are not interactive, the runtime spawns the debugger listed in the DbgManagedDebugger registry key. This is the default setting for the .NET Framework version 2.0.

See Also

Concepts

Making an Image Easier to Debug
Enabling Profiling

Other Resources

Debugging and Profiling Applications