Disable debug prompt on application crash

后端 未结 3 1986
挽巷
挽巷 2020-12-09 12:58

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

Background: We\'ve got an application that syncs info w

相关标签:
3条回答
  • 2020-12-09 13: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 
    
    0 讨论(0)
  • 2020-12-09 13:10

    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"=-
    
    0 讨论(0)
  • 2020-12-09 13:27

    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

    0 讨论(0)
提交回复
热议问题