crashwindbgwindows-error-reportingpostmortem-debuggingprocdump

Automatic Crash Dump for .Net process


I'm trying to set up a Windows Server 2016 instance to automatically create a crash dump when a .Net process exits with an unhandled exception. I've tried the following:

I've tried running my application in a way that will generate an exception. All I have to do is start it twice in the same configuration, and the second instance crashes on a socket bind exception. However, in none of the cases above does the crash generate a dump file. Is there something special I have to do on Windows Server 2016, or something special I need to do to my .Net application to get it to trigger a dump on an unhandled exception?


Solution

  • I found the reason: we are using TopShelf to host our process. By default TopShelf handles uncaught exceptions and exits cleanly.

    For any who come afterwards, please note that TopShelf has an undocumented feature from late last year to disable this behavior:

    x.UnhandledExceptionPolicy = Topshelf.Runtime.UnhandledExceptionPolicyCode.TakeNoAction;

    in the service configuration will do it. With this code, I was able to get a crash dump.