Should I derive custom exceptions from Exception or ApplicationException in .NET?

You should derive custom exceptions from System.Exception.

Even MSDN now says to ignore ApplicationException:

If you are designing an application that needs to create its own exceptions, you are advised to derive custom exceptions from the Exception class. It was originally thought that custom exceptions should derive from the ApplicationException class; however in practice this has not been found to add significant value. For more information, see Best Practices for Handling Exceptions.

http://msdn.microsoft.com/en-us/library/system.applicationexception.aspx


According to Jeffery Richter in the Framework Design Guidelines book:

System.ApplicationException is a class that should not be part of the .NET framework.

It was intended to have some meaning in that you could potentially catch "all" the application exceptions, but the pattern was not followed and so it has no value.

Tags:

.Net

Exception