Get stack trace for a C # application with an error on a machine other than dev

I installed a Windows C # forms application on a client computer that does not have Visual Studio installed.

When the application starts, it immediately crashes with a dialog box saying: "ProgramX has stopped working. The problem has caused the program to stop working correctly. Close the program." The only button in the dialog box is "close the program."

I would like to see an exception message and a stack trace so that I can diagnose the problem.

I tried installing the .Net SDK that comes with "windbg". I ran the program in windbg and managed to get it to say "CLR exception". However, I cannot get windbg to print an exception message or a stack trace. It will not load SOS or PSSCOR2 due to loading DLL messages, even after many attempts. There should be an easier way!

(If your answer includes windbg, please provide detailed step-by-step instructions as I tried and failed to complete this approach.)

The application is an .Net 3.5 application. .Net 3.5 and .Net 4 are installed on the machine. There is nothing in the event log (I can find).

+4
source share
3 answers

If you do not have access to the source code , you will have a problem. Exceptions must end in Windows events. Maybe the exception is suppressed.

If you have access to the source code , you can combine the source code with TRY \ CATCH and in CATCH and print the exception information into a file:

  • ex.message
  • ex.InnerException.Message
  • ex.StackTrace

The code

try { //Your code } catch (Exception ex) { //Log info to a file in same directory } 
+3
source

Use ADPlus to get the application crash dump and load the crash dump into WinDbg on your development machine:

http://blogs.msdn.com/b/webdav_101/archive/2008/09/04/howto-generating-a-crash-dump-with-adplus.aspx

http://support.microsoft.com/kb/286350

You can also try setting up remote debugging (assuming you have the source code):

http://msdn.microsoft.com/en-us/library/y7f5zaaa.aspx

+2
source
  • You can catch unhandled exceptions in one place in your code by adding a handler to the next event. Then you can register or perform other actions.

    AppDomain.UnhandledException

  • You can create a crash dump from the task manager (right-click on the entries in the Processes tab and select Create Dump File ) and load it using WinDbg. Running the !pe command should throw an exception. You will need the PDB files from your assembly and the correct version of the SOS DLL from the computer that crashed.

+2
source

All Articles