Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Handling rude application aborts in .NET

I know I'm opening myself to a royal flaming by even asking this, but I thought I would see if StackOverflow has any solutions to a problem that I'm having...

I have a C# application that is failing at a client site in a way that I am unable to reproduce locally. Unfortunately, it is very difficult (impossible) for me to get any information that at all helps in isolating the source of the problem.

I have in place a rather extensive error monitoring framework which is watching for unhandled exceptions in all the usual places:

  • Backstop exception handler in threads I control
  • Application.ThreadException for WinForms exceptions
  • AppDomain.CurrentDomain.UnhandledException

Which logs detailed information in a place where I have access to them.

This has been very useful in the past to identify issues in production code, but has not been giving me any information at about the current series of issues.

My best guess is that the core issue is one of the "rude" exception types (thread abort, out of memory, stack overflow, access violation, etc.) that are escalating to a rude shutdown that are ripping down the process before I have a chance to see what is going on.

Is there anything that I can be doing to snapshot information as my process is crashing that would be useful? Ideally, I would be able to write out my custom log format, but I would be happy if I could have a reliable way of ensuring that a crash dump is written somewhere.

I was hoping that I could implement class deriving from CriticalFinalizerObject and have it spit a last-chance error log out when it is disposing, but that doesn't seem to be triggered in the StackOverflow scenario which I tested.

I am unable to use Windows Error Reporting and friends due to the lack of a code signing certificate.

I'm not trying to "recover" from arbitrary exceptions, I'm just trying to make a note of what went wrong on the way down.

Any ideas?

like image 811
StarBright Avatar asked Nov 05 '22 16:11

StarBright


1 Answers

You could try creating a minidump file. This is a C++ API, but it should be possible to write a small C++ program that starts your application keeps a handle to the process, waits on the process handle, and then uses the process handle to create a minidump when the application dies.

like image 143
John Knoeller Avatar answered Nov 14 '22 00:11

John Knoeller