FAQ: Why do some sources recommend extending ApplicationException while FxCop does not? [Michael Fanning, David Kean]

TypesShouldNotExtendCertainBaseTypes fires on types that derive from ApplicationException and DoNotRaiseReservedExceptionTypes on members that throw ApplicationException. Why?

There are several outdated documents floating around on the web (some orginally published by Microsoft) recommending that application developers extend ApplicationException. However, this guidance was revised several years ago for a couple of reasons:

  • It deepens the class hierarchy and presents additional complications for consumers writing exception handlers without providing additional value.
  • It prevents the reuse of existing exception classes defined in the Base Class Library (BCL).

The official Microsoft Design Guidelines, particularly the Catching and Throwing Standard Exception Types section, have only recently been revamped to include this new information. Both Krzysztof Cwalina and Brad Abrams, who own the Framework Design Guidelines at Microsoft, have both blogged on this issue (ApplicationException considered useless and Introducing the .NET Framework Standard Library Annotated Reference).

If you see any MSDN samples or articles that use ApplicationException (or violate any FxCop rule, for that matter), please file a bug on the Microsoft Connect.

Comments (7)

  1. Your link to "Catching and throwing Standard Exception Types" appears to be broken.

  2. mcgurk says:

    Rock on!  Where can I get aholt of the bass class library?  I’ve got some killer riffs I want to implement!

  3. davkean says:

    Fixed and Fixed. 😉

  4. Peter says:

    The Product Feedback link is broken (gives me a generic error with this URL: http://lab.msdn.microsoft.com/productfeedback/Error.aspx?errtype=http&errno=500) so I’ll enter it here instead.

    These new recommendations–"don’t throw ApplicationException and don’t derive from it"–coupled with the fact that ApplicationException is by definition not something the Framework will derive/throw, begs the question: What’s the ApplicationException class to be used for now? And if the answer is "nothing," why isn’t it marked as obsolete, since the recommendation in Brad’s entry came out nearly 18 months ahead of .NET 2.0?

    And when you say "several outdated documents floating around on the web," these include the official Microsoft .NET Framework documentation:


    I can certainly understand the reasons for reversing your advice regarding ApplicationException, I just wonder why the FxCop and a couple other blogs are the only ones that say so, and not more high-profile sources like the docs.

  5. davkean says:


    The Microsoft Design Guidelines (as linked above) are the correct docs. I will file a bug internally regarding the ApplicationException docs.

    Existing code both internally and externally derive from ApplicationException. As it is a breaking change to change the base of a class (especially an Exception), it can’t be marked obsolete.

  6. The ApplicationException documentation has now been fixed: http://msdn2.microsoft.com/en-US/library/system.applicationexception(VS.80).aspx.

Skip to main content