Unhandled Addin Exceptions vs. Visual Studio

Keep your addin from crashing visual studio

Published on Saturday, February 9, 2008

One of the most frustrating things I've found when programming addins for visual studio is the inability to globally trap unhandled exceptions the way that you can when  authoring a windows application.  Essentially visual studio intercepts exceptions your addin throws that you neglect to handle.  The worst part is that you don't get any information about the exception before visual studio crashes!  Its great that Microsoft gets a dump of the crash, but you're left standing empty handed and scratching your head.

Generally speaking an addin framework should not allow an addin to crash the host application.  It points to either a design concept that I can't comprehend, a significant oversight in the design of the visual studio addin framework, or simply some kind of interop issue that visual studio doesn't handle well.

Short of making sure that every block of code in your addin that can throw an exception is wrapped in a try block we don't have a good methodology for dealing with unhandled exceptions.  While this is a good thing because it forces you to write solid code it can be exceptionally frustrating to to debug unforeseen issues in a production environment.

I'm still looking for a good way to trap or instrument unhandled exceptions in addins that I write, especially in runtime environments.  If I find a good approach I'll be sure to write about it.