调试崩溃的exe而不引发AppDomain.UnhandledException

时间:2012-12-11 20:27:28

标签: .net windows

我有一个在Visual Studio中正常运行的exe。当我将其部署到Windows Server时,它会崩溃 - 即使我正在尝试捕获其未处理的异常,如下面的代码所示。代码 DOES 捕获VS中预期的未处理异常(即它在msg框中显示异常对象)。当代码在服务器上崩溃时,它让我有机会在Visual Studio中“调试”代码,提供如下所示的读数。

  1. 为什么我的异常处理程序没有显示msg框?
  2. 如何解读此崩溃读数?
  3. Sub Main(ByVal args() As String)
    
        AddHandler AppDomain.CurrentDomain.UnhandledException, AddressOf errorReporter
    
        Dim myProcess As AutomatedProcessVB = New AutomatedProcessVB("Laphie")
    
        myProcess.run()
    
    End Sub
    
    Private Sub errorReporter(sender As Object, e As System.UnhandledExceptionEventArgs)
        MsgBox(e.ExceptionObject.ToString)
        Environment.Exit(3)
    End Sub
    

    以下是程序崩溃时的输出:

    'AutoMatcher.exe': Loaded 'D:\Executables\AutoMatcher.exe', No native symbols in symbol file.
    'AutoMatcher.exe': Loaded 'C:\Windows\System32\ntdll.dll', No symbols loaded.
    'AutoMatcher.exe': Loaded 'C:\Windows\System32\kernel32.dll', No symbols loaded.
    'AutoMatcher.exe': Loaded 'C:\Windows\System32\sysfer.dll', No symbols loaded.
    'AutoMatcher.exe': Loaded 'C:\Windows\System32\mscoree.dll', No symbols loaded.
    'AutoMatcher.exe': Loaded 'C:\Windows\System32\advapi32.dll', No symbols loaded.
    'AutoMatcher.exe': Loaded 'C:\Windows\System32\rpcrt4.dll', No symbols loaded.
    'AutoMatcher.exe': Loaded 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\mscoreei.dll', No symbols loaded.
    'AutoMatcher.exe': Loaded 'C:\Windows\System32\shlwapi.dll', No symbols loaded.
    'AutoMatcher.exe': Loaded 'C:\Windows\System32\gdi32.dll', No symbols loaded.
    'AutoMatcher.exe': Loaded 'C:\Windows\System32\user32.dll', No symbols loaded.
    'AutoMatcher.exe': Loaded 'C:\Windows\System32\msvcrt.dll', No symbols loaded.
    'AutoMatcher.exe': Loaded 'C:\Windows\System32\imm32.dll', No symbols loaded.
    'AutoMatcher.exe': Loaded 'C:\Windows\System32\msctf.dll', No symbols loaded.
    'AutoMatcher.exe': Loaded 'C:\Windows\System32\lpk.dll', No symbols loaded.
    'AutoMatcher.exe': Loaded 'C:\Windows\System32\usp10.dll', No symbols loaded.
    'AutoMatcher.exe': Loaded 'C:\Windows\winsxs\x86_microsoft.windows.common-controls_6595b64144ccf1df_6.0.6002.18305_none_5cb72f2a088b0ed3\comctl32.dll', No symbols loaded.
    'AutoMatcher.exe': Loaded 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll', No symbols loaded.
    'AutoMatcher.exe': Loaded 'C:\Windows\System32\msvcr100_clr0400.dll', No symbols loaded.
    'AutoMatcher.exe': Loaded 'C:\Windows\assembly\NativeImages_v4.0.30319_32\mscorlib\16126cae96ea2422253ae06eeb672abc\mscorlib.ni.dll', No symbols loaded.
    'AutoMatcher.exe': Loaded 'C:\Windows\System32\ole32.dll', No symbols loaded.
    'AutoMatcher.exe': Loaded 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\Culture.dll', No symbols loaded.
    'AutoMatcher.exe': Loaded 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\nlssorting.dll', No symbols loaded.
    'AutoMatcher.exe': Loaded 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\clrjit.dll', No symbols loaded.
    'AutoMatcher.exe': Loaded 'C:\Windows\System32\rsaenh.dll', No symbols loaded.
    'AutoMatcher.exe': Loaded 'C:\Windows\assembly\NativeImages_v4.0.30319_32\System\811a7bc79f8f0a5be8065292a320819e\System.ni.dll', No symbols loaded.
    'AutoMatcher.exe': Loaded 'C:\Windows\assembly\NativeImages_v4.0.30319_32\System.Core\752225ca2585aa8f1c46b489e172e920\System.Core.ni.dll', No symbols loaded.
    'AutoMatcher.exe': Loaded 'C:\Windows\assembly\NativeImages_v4.0.30319_32\System.Data.Linq\df6307904c34b42871857eb60ceb338f\System.Data.Linq.ni.dll', No symbols loaded.
    'AutoMatcher.exe': Loaded 'C:\Windows\assembly\NativeImages_v4.0.30319_32\Microsoft.VisualBas#\da70ab23582f4ebf61a2d551a390afcf\Microsoft.VisualBasic.ni.dll', No symbols loaded.
    'AutoMatcher.exe': Loaded 'C:\Windows\assembly\NativeImages_v4.0.30319_32\System.Drawing\9422d0c052186760a4645e10995487f5\System.Drawing.ni.dll', No symbols loaded.
    'AutoMatcher.exe': Loaded 'C:\Windows\assembly\NativeImages_v4.0.30319_32\System.Windows.Forms\caffbced23ee85b40b919ad4a122b7aa\System.Windows.Forms.ni.dll', No symbols loaded.
    'AutoMatcher.exe': Loaded 'C:\Windows\winsxs\x86_microsoft.windows.common-controls_6595b64144ccf1df_5.82.6002.18305_none_88f3a38569c2c436\comctl32.dll', No symbols loaded.
    'AutoMatcher.exe': Loaded 'C:\Windows\assembly\NativeImages_v4.0.30319_32\System.Configuration\ed886fb71addf400705481dcf8de12da\System.Configuration.ni.dll', No symbols loaded.
    'AutoMatcher.exe': Loaded 'C:\Windows\assembly\NativeImages_v4.0.30319_32\System.Xml\cb0c00757e89f0b1fe282913ed667212\System.Xml.ni.dll', No symbols loaded.
    'AutoMatcher.exe': Loaded 'C:\Windows\System32\urlmon.dll', No symbols loaded.
    'AutoMatcher.exe': Loaded 'C:\Windows\System32\oleaut32.dll', No symbols loaded.
    'AutoMatcher.exe': Loaded 'C:\Windows\System32\iertutil.dll', No symbols loaded.
    'AutoMatcher.exe': Loaded 'C:\Windows\System32\ntmarta.dll', No symbols loaded.
    'AutoMatcher.exe': Loaded 'C:\Windows\System32\Wldap32.dll', No symbols loaded.
    'AutoMatcher.exe': Loaded 'C:\Windows\System32\ws2_32.dll', No symbols loaded.
    'AutoMatcher.exe': Loaded 'C:\Windows\System32\nsi.dll', No symbols loaded.
    'AutoMatcher.exe': Loaded 'C:\Windows\System32\psapi.dll', No symbols loaded.
    'AutoMatcher.exe': Loaded 'C:\Windows\System32\samlib.dll', No symbols loaded.
    'AutoMatcher.exe': Loaded 'C:\Windows\System32\version.dll', No symbols loaded.
    'AutoMatcher.exe': Loaded 'C:\Windows\System32\secur32.dll', No symbols loaded.
    'AutoMatcher.exe': Loaded 'C:\Windows\System32\shell32.dll', No symbols loaded.
    'AutoMatcher.exe': Loaded 'C:\Windows\System32\shfolder.dll', No symbols loaded.
    'AutoMatcher.exe': Loaded 'C:\Windows\assembly\NativeImages_v4.0.30319_32\System.Data\90f1acbd79e2a5fabfb8c516d6be36a3\System.Data.ni.dll', No symbols loaded.
    'AutoMatcher.exe': Loaded 'C:\Windows\Microsoft.NET\assembly\GAC_32\System.Data\v4.0_4.0.0.0__b77a5c561934e089\System.Data.dll', No symbols loaded.
    'AutoMatcher.exe': Loaded 'C:\Windows\System32\crypt32.dll', No symbols loaded.
    'AutoMatcher.exe': Loaded 'C:\Windows\System32\msasn1.dll', No symbols loaded.
    'AutoMatcher.exe': Loaded 'C:\Windows\System32\userenv.dll', No symbols loaded.
    'AutoMatcher.exe': Loaded 'C:\Windows\assembly\NativeImages_v4.0.30319_32\System.Transactions\102cfe160aeb1e16a35890004a421ec9\System.Transactions.ni.dll', No symbols loaded.
    'AutoMatcher.exe': Loaded 'C:\Windows\Microsoft.NET\assembly\GAC_32\System.Transactions\v4.0_4.0.0.0__b77a5c561934e089\System.Transactions.dll', No symbols loaded.
    'AutoMatcher.exe': Loaded 'C:\Windows\assembly\NativeImages_v4.0.30319_32\System.EnterpriseSe#\6fc86a3e1d07ea824cd49b0c0b19d2f5\System.EnterpriseServices.ni.dll', No symbols loaded.
    'AutoMatcher.exe': Loaded 'C:\Windows\assembly\NativeImages_v4.0.30319_32\System.EnterpriseSe#\6fc86a3e1d07ea824cd49b0c0b19d2f5\System.EnterpriseServices.Wrapper.dll', No symbols loaded.
    'AutoMatcher.exe': Loaded 'C:\Windows\Microsoft.NET\assembly\GAC_32\System.EnterpriseServices\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.EnterpriseServices.Wrapper.dll', No symbols loaded.
    'AutoMatcher.exe': Loaded 'C:\Windows\System32\security.dll', No symbols loaded.
    'AutoMatcher.exe': Loaded 'C:\Windows\System32\credssp.dll', No symbols loaded.
    'AutoMatcher.exe': Loaded 'C:\Windows\System32\schannel.dll', No symbols loaded.
    'AutoMatcher.exe': Loaded 'C:\Windows\System32\netapi32.dll', No symbols loaded.
    'AutoMatcher.exe': Loaded 'C:\Windows\System32\PwdSSP.dll', No symbols loaded.
    'AutoMatcher.exe': Loaded 'C:\Windows\System32\kerberos.dll', No symbols loaded.
    'AutoMatcher.exe': Loaded 'C:\Windows\System32\cryptdll.dll', No symbols loaded.
    'AutoMatcher.exe': Loaded 'C:\Windows\System32\msv1_0.dll', No symbols loaded.
    'AutoMatcher.exe': Loaded 'C:\Windows\System32\ntdsapi.dll', No symbols loaded.
    'AutoMatcher.exe': Loaded 'C:\Windows\System32\dnsapi.dll', No symbols loaded.
    'AutoMatcher.exe': Loaded 'C:\Windows\System32\mswsock.dll', No symbols loaded.
    'AutoMatcher.exe': Loaded 'C:\Windows\System32\WSHTCPIP.DLL', No symbols loaded.
    'AutoMatcher.exe': Loaded 'C:\Windows\System32\wship6.dll', No symbols loaded.
    'AutoMatcher.exe': Loaded 'C:\Windows\System32\nlaapi.dll', No symbols loaded.
    'AutoMatcher.exe': Loaded 'C:\Windows\System32\IPHLPAPI.DLL', No symbols loaded.
    'AutoMatcher.exe': Loaded 'C:\Windows\System32\dhcpcsvc.dll', No symbols loaded.
    'AutoMatcher.exe': Loaded 'C:\Windows\System32\winnsi.dll', No symbols loaded.
    'AutoMatcher.exe': Loaded 'C:\Windows\System32\dhcpcsvc6.dll', No symbols loaded.
    'AutoMatcher.exe': Loaded 'C:\Windows\System32\NapiNSP.dll', No symbols loaded.
    'AutoMatcher.exe': Loaded 'C:\Windows\System32\winrnr.dll', No symbols loaded.
    'AutoMatcher.exe': Loaded 'C:\Windows\System32\rasadhlp.dll', No symbols loaded.
    'AutoMatcher.exe': Loaded 'C:\Windows\System32\dssenh.dll', No symbols loaded.
    'AutoMatcher.exe': Loaded 'C:\Windows\System32\ncrypt.dll', No symbols loaded.
    'AutoMatcher.exe': Loaded 'C:\Windows\System32\bcrypt.dll', No symbols loaded.
    'AutoMatcher.exe': Loaded 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\diasymreader.dll', No symbols loaded.
    'AutoMatcher.exe': Loaded 'C:\Windows\System32\apphelp.dll', No symbols loaded.
    The thread 'Win32 Thread' (0x2d70) has exited with code 0 (0x0).
    Unhandled exception at 0x7719fc56 in AutoMatcher.exe: 0xE0434352: 0xe0434352.
    The thread 'Win32 Thread' (0x808) has exited with code -2146233082 (0x80131506).
    The thread 'Win32 Thread' (0x2a94) has exited with code -2146233082 (0x80131506).
    The thread 'Win32 Thread' (0x1d14) has exited with code -2146233082 (0x80131506).
    The thread 'Win32 Thread' (0x1ea4) has exited with code -2146233082 (0x80131506).
    The thread 'Win32 Thread' (0x221c) has exited with code -2146233082 (0x80131506).
    The program '[9572] AutoMatcher.exe: Native' has exited with code -2146233082 (0x80131506).
    

1 个答案:

答案 0 :(得分:1)

  

围绕整个程序的try-catch块捕获所有错误并将它们写入文件

这是一个令人不安的选择。如果程序在创建文件时有任何问题,那么肯定也会在创建日志文件以报告错误时遇到问题。所以你也没有看到错误。至少也使用Console.WriteLine()。

此类问题的典型原因是您创建了文件而未指定文件的完整路径名。因此,您将严格依赖于正确设置的程序的默认目录。从桌面启动时与从命令行提示符启动时不一样。并且要注意,如果没有UAC提升,您可以写很少的地方。始终指定文件的完整路径名,使用Environment.GetFolderPath()查找可写目录。