tags:

views:

62

answers:

3

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

I've found two controversial thoughts in MSDN for this matter.

If you are designing an application that needs to create its own exceptions, derive from the ApplicationException class.

Source

For most applications, derive custom exceptions from the Exception class.

Source

Additionally when I took some practice test for 70-536 there was similar question and as right answer was marked ApplicationException.

What is the official guideline?

+6  A: 

ApplicationException was the first recommendation, but after a while MS decided that it just increased the inheritance depth without giving any advantage so they changed the recommendation to just use Exception.

You can find some more information (including a quote explaining the rationale) in this blog post: http://blogs.msdn.com/b/kcwalina/archive/2006/06/23/644822.aspx

ho1
+1  A: 

Good question. The short answer is that the ApplicationException class in unofficially deprecated/obsolete, for a number of reasons. (The main one is perhaps that the exception type should/need not indicate source (that's what the Source property is for.)

Originally (.NET 1.x days I believe) it was intended that you would derive all custom exception classes from it to differentiate from BCL exceptions, but this was later (rightly in my view) disregarded. The common/good practice these days is to derive all custom exception classes directly from Exception (or other custom classes).

Noldorin
+1  A: 

Exception is your best bet, in my opinion.

In my opinion and some others that I have read, ApplicationException was a overengineering at its best.

There are more opinions here

Sky Sanders