1

I have an exe that works properly in Visual Studio. When I deploy it to Windows Server, it crashes -- even though I am trying to catch its unhandled exceptions, as shown in the code below. The code DOES catch unhandled exceptions as expected in VS (i.e. it displays the exception object in a msg box). When the code crashes on the server, it offers me the chance to 'debug' the code in Visual Studio, providing the readout shown below.

  1. Why is my exception handler not displaying a msg box?
  2. How do I interpret this crash readout?
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

Here is the output when the program crashes:

'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).
Mark Hurd
  • 10,665
  • 10
  • 68
  • 101
bernie2436
  • 22,841
  • 49
  • 151
  • 244
  • Maybe there's something in the environment it needs that's provided from the GUI, but not from the shell? I've seen cases where the environment settings differed between the two. – RonaldBarzell Dec 11 '12 at 20:29
  • it is dependent on a few custom dlls that are in the folder with it. would it not have access to those if launched from the cmd shell? – bernie2436 Dec 11 '12 at 20:31
  • Possibly; in fact, the setting that I found differed was usually the path. Check the path in both cases. – RonaldBarzell Dec 11 '12 at 20:32
  • by check the path do you mean check that the exe and the gui are pointing to the same place. i have done that. – bernie2436 Dec 11 '12 at 20:37
  • Try typing "path" at the command line and see if the paths to the DLLs are there. If everything looks good, I recommend adding logging at various points to see what's going on. – RonaldBarzell Dec 11 '12 at 20:39
  • I have added the path to the directory that holds the executable to the "path" environment variable in the command shell but am still still seeing this problem. What do you mean by "logging in at variables points" – bernie2436 Dec 11 '12 at 21:00
  • Where are you trying to write the file (which folder) in each case? This sounds like it might be a folder virtualization issue, where one of the executions of the app doesn't have write access to the destination folder (and the other one does). – Ken White Dec 11 '12 at 21:06
  • @akh2103: I mean adding some code in various spots to output the key parts of your program state, so you can see just what it fails to get. For instance, if your program depends on X, Y and Z, add logging to show their values, or at least whether they are initialized... – RonaldBarzell Dec 11 '12 at 21:07

1 Answers1

1

a try-catch block encircling the whole program catches all errors and writes them to a file

That is a troubling choice. If the program has any problem creating the file then surely it will also have trouble creating the log file to report the error. So you don't see the error either. At least use Console.WriteLine() as well.

A typical cause of a problem like this is that you created the file without specifying the full path name of the file. So you'll critically depend on the program's default directory being set correctly. Which won't be the same when launched from the desktop vs started from a command line prompt. And do beware that there are few places you can write to without UAC elevation. Always specify the full pathname of the file, use Environment.GetFolderPath() to find a writable directory.

Hans Passant
  • 922,412
  • 146
  • 1,693
  • 2,536
  • you are correct. the program errors out when i take out the try-catch block. It runs fine in visual studio, but the exe crashes when deployed on the server. how can i debug the program if i can't write out its errors to a file? the server allows me to "debug the error in visual studio" but the error just reads an unhandled exception at hexVal in program.exe: hex value – bernie2436 Dec 13 '12 at 15:41
  • Write an event handler for AppDomain.CurrentDomain.UnhandledException. Display or log the value of e.ExceptionObject.ToString() so you *know* where and why it failed. – Hans Passant Dec 13 '12 at 15:43
  • I tried adding a handler as you suggest (see code above). It catches unhandled errors when I run it in visual studio (it caught an intentional divide by zero error). But when I run it on the server, the program still crashes, offers to let me 'debug it' in visual studio and then gives the same hex about unhandled exceptions. Is there some reason my handler would not catch exceptions on the server? What can I do? – bernie2436 Dec 13 '12 at 16:37
  • My condolences: http://stackoverflow.com/questions/2823440/troubleshooting-net-fatal-execution-engine-error/3081277#3081277 – Hans Passant Dec 13 '12 at 17:26