views:

313

answers:

5

One of our .NET 2.0 application started to just randomly disappear. There are no records in the Event log, Dr. Watson doesn't generate crash dump, no nothing...

How to troubleshoot this application?

+4  A: 

1) Attach an event handler to AppDomain.UnhandledException event and log the exception object.

AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);

2) Attach a thread exception handler

Application.ThreadException +=
  new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);

For WPF and Silverlight apps you use more exception handlers, e.g. Application.DispatcherUnhandledException and Application.UnhandledException respectively, but these are not of interest to you in this scenario. I include them for completeness.

_NT
It is handled - no log record.
alex
+2  A: 

Modify the code to include log steps after each relevant section, and then check the log file to see where its going.

If it doesn't even start, then that'll tell you something too...

Nick Haslam
+1  A: 

More possibilities:

ewall
A: 

You could try using Elmah, this will log almost all unhandled exceptions:

http://www.hanselman.com/blog/ELMAHErrorLoggingModulesAndHandlersForASPNETAndMVCToo.aspx

Shiraz Bhaiji
+1  A: 

We had a similar issue. We had an event for the AppDomain.UnhandledException but it was even skipping this. It turned out to be an SystemAccessViolation caused when we tested the clipboard contents.

If it's similar (EG skipping AppDomain.UnhandledException event) then I'd suggest log everything around interop and 'hostile' data calls from outside of your process and code review it all. It took us several weeks to track it down and a one line change to fix it.

Also, turn on MDAs in VS and run your program with it and see if you get errors.

L2Type