Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable debug prompt on application crash

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.

Thanks, Brian

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

like image 294
used2could Avatar asked Feb 17 '10 20:02

used2could


People also ask

How do I stop just-in-time debugging pop ups?

Enable or disable Just-In-Time debugging in Visual Studio You can configure Just-In-Time debugging from the Visual Studio Tools > Options (or Debug > Options) dialog box. To enable or disable Just-In-Time debugging: On the Tools or Debug menu, select Options > Debugging > Just-In-Time.

Why does JIT debugging keep popping up?

The Just-In-Time Debugger dialog box may open when an error occurs in a running app, and prevent the app from continuing. The Just-In-Time Debugger gives you the option to launch Visual Studio to debug the error.

How do you debug a crashed application?

You can use the stack trace available in the report details if you are using Play Console or the output of the logcat tool. If you don't have a stack trace available, you should locally reproduce the crash, either by manually testing the app or by reaching out to affected users, and reproduce it while using logcat.


3 Answers

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 
like image 142
John Knoeller Avatar answered Sep 28 '22 09:09

John Knoeller


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

like image 40
Roland Pihlakas Avatar answered Sep 28 '22 08:09

Roland Pihlakas


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"=-
like image 43
2 revs, 2 users 91% Avatar answered Sep 28 '22 08:09

2 revs, 2 users 91%