Disable debug prompt on application crash
Asked Answered
T

4

9

Question: I need to disable the console application's crash debug prompt.

Background: We've got an application that syncs info with a third party that crashes due to connectivity problems with the 3rd party at certain times of the day. We don't have access to the source code to trap the error properly so I just need the application to fail and try again. I've got another application that monitors our sync tool to make sure it's running.

when the sync apps crashes there is a debug prompt that requires a users interaction. Because this stays on the screen the application never actually stops running. As a result the "health check" never knows of the failure.

I've done this about 2 years ago but for the life of me I can't the remember the article or the needed registry path.

OS: Windows 2003 Server Application Type: .NET 3.5 Console Application


FIX: found by: John Knoeller

Delete the following keys

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AeDebug\Debugger HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft
.NETFramework\DbgManagedDebugger

Tarragon answered 17/2, 2010 at 20:28 Comment(2)
The community wiki accepted answer on #3562045 is also a very useful resource.Goulden
Similar: #735670Corrinnecorrival
M
10

Possibly this?

How to: Enable/Disable Just-In-Time Debugging

The registry keys are

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AeDebug\Debugger
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\DbgManagedDebugger 
Marylinmarylinda answered 17/2, 2010 at 20:31 Comment(2)
EXACTLY!! Thank you! Note: scroll down to the registry path if u don't have VS installed HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AeDebug\Debugger HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\DbgManagedDebuggerTarragon
The link is dead, it would be better to provide an answer and not just a link (see meta.stackexchange.com/a/8259).Ripley
C
6

Deleting entire keys seems too "hammer" approach.

First, one can use Windows API functions SetErrorMode and/or SetThreadErrorMode. They can be PInvoked from .NET application too.

The related signatures for PInvoke are:

    public enum ErrorMode : uint
    {
        SEM_DEFAULT                 = 0x0000,
        SEM_FAILCRITICALERRORS      = 0x0001,
        SEM_NOGPFAULTERRORBOX       = 0x0002,
        SEM_NOALIGNMENTFAULTEXCEPT  = 0x0004,
        SEM_NOOPENFILEERRORBOX      = 0x8000
    }

    [DllImport("Kernel32.dll")]
    public static extern ErrorMode SetErrorMode(ErrorMode mode);  //available since XP

    [DllImport("Kernel32.dll")]
    public static extern ErrorMode GetErrorMode();  //available since Vista

    [DllImport("kernel32.dll", SetLastError = true)]
    public static extern bool SetThreadErrorMode(ErrorMode newMode, out ErrorMode oldMode);    //available since Windows 7

    [DllImport("Kernel32.dll")]
    public static extern ErrorMode GetThreadErrorMode();    //available since Windows 7


Secondly, there is a more specific registry-based solution since Vista:
Excluding only this application from being debugged. See this:

http://msdn.microsoft.com/en-us/library/windows/desktop/bb204634(v=vs.85).aspx

Copy-paste:

Excluding an Application from Automatic Debugging

The following procedure describes how to exclude an application from automatic debugging after the Auto value under the AeDebug key has been set to 1.

--> To exclude an application from automatic debugging go to the following registry key:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AeDebug
Add a REG_DWORD value to the AutoExclusionList subkey, where the name is the name of the executable file and the value is 1.
By default, the Desktop Window Manager (Dwm.exe) is excluded from automatic debugging because otherwise a system deadlock can occur if Dwm.exe stops responding (the user cannot see the interface displayed by the debugger because Dwm.exe isn't responding, and Dwm.exe cannot terminate because it is held by the debugger).
Windows Server 2003 and Windows XP: The AutoExclusionList subkey is not available; thus you cannot exclude any application, including Dwm.exe, from automatic debugging.

The default AeDebug registry entries can be represented as follows:
HKEY_LOCAL_MACHINE SOFTWARE Microsoft Windows NT CurrentVersion AeDebug Auto = 1 AutoExclusionList DWM.exe = 1

Cadmium answered 8/8, 2014 at 23:52 Comment(1)
+1, requiring a registry key change on each machine the program is running would be frustrating. Much better with an API call!Samal
A
2

John's solution as a .reg file (we needed to roll this out to a cluster of build servers):

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AeDebug]
"Debugger"=-

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework]
"DbgManagedDebugger"=-
Acosmism answered 17/2, 2010 at 20:28 Comment(0)
R
0

An update on John's answer:

Taken from the MSDocs reference of How to: Enable/Disable Just-In-Time Debugging:

The registry key to delete is

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AeDebug\Debugger

If running managed code, also this:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\DbgManagedDebugger 

If running 32 bit code on 64bit machine, this as well:

HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows NT\CurrentVersion\AeDebug\Debugger
Restate answered 30/10, 2022 at 5:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.