ASP.Net Unhandled Exception Handling: Email exception with MiniDump

By | 2010.07.02

For most ASP.Net applications I make I add some code that emails me any unhandled exceptions. This way I immediately know when something has gone wrong with an application. The email contains a lot of useful information, including a MiniDump of the process.

If you are not familiar with it, a MiniDump is a snapshot of the process when it failed which can be loaded into Visual Studio as a “paused project”. You can look at stack trace, locals, execute Immediate commands, etc. You can also use WinDbg to load it with CLR extensions for some in-depth debugging. Very handy.

Using this with Microsoft Azure Cloud apps will ensure proper debugging capability even when you can’t attach a debugger or log on and read the event log.

Also: You don’t have to recreate the exception because you already have a breakpoint where it happened in the code. No more poor bug reports or elusive bugs.

A couple of points before we get on to the code:

  • Uses Nini for config reading, so you need to reference it from your project.
  • Needs write-rights to a folder for MiniDump to work.
  • You have to change: Global.asax and Web.Config
  • You have to create a new class called ApplicationErrorHandler and put the main class in it.

To implement, add this to Global.asax (add a Global.asax if you don’t have it already):

The main class:

And web.config needs some additional info:

One thought on “ASP.Net Unhandled Exception Handling: Email exception with MiniDump

  1. poker regeln

    I should digg your article so more people are able to see it, very helpful, I had a tough time finding the results searching on the web, thanks.

    – Joe

    Reply

Leave a Reply