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.