Goodbye ApplicationException!

While researching on Visual Studio Static Code Analysis topics I came over blog posts by Brad Abrams and Krzysztof Cwalina (who wrote the Framework Design Guidelines)!

The both ask developers to stop using ApplicationException as a base class for custom exceptions. Although this was advised before, now they decided to discontinue this guideline for exception inheritance for several reasons:

  • Originally it was planned to just let custom exceptions derive from ApplicationException: Unfortunately some CLR/BCL exceptions also derive from it (like TargetInvocationException)!
  • Catching all ApplicationExceptions can therefore not be done any longer (as this would also catch TargetInvocationException and others). Also you shouldn't basically catch ALL ApplicationExceptions in one block (like you shouldn't catch ALL Exceptions), but differ to several sub-Exceptions!
  • So deriving from ApplicationException just adds unnecessary depth to your exception tree!