+4  A: 

This is all discussed in the Design Guidelines document.

Cheeso
Very interesting. I hadn't realized that ApplicationException was essentially declared obsolete, in a sense.
BlueMonkMN
Pretty much .... it says pretty clearly that you shouldn't use it !!! That's good enuff for me :)
IbrarMumtaz
+2  A: 

In general, you want to derive from the Exception class which most closely resembles the type of exception you want to throw. If the trouble is that some Argument or Parameter has been passed which causes a problem, use ArgumentException. If you need some customization with that, inherit from ArgumentException.

In my experience, the only two reasons to use the base Exception are: 1) when you need some custom exception that completely does not fit one of the current exception models or 2) When a method could theoretically throw a number of exceptions, but you've already caught the ones you find most likely to be thrown.

Typically, I don't inherit from exceptions at all. Simply setting the Message property tends to be enough.

AllenG
thanks for the reply. I will take bear that in mind when am reading the design guidelines document.
IbrarMumtaz
+3  A: 

In our most recent project we used a base exception class. We used it to get the following functionality:

  • All exceptions needed a number, so defining the property for the number was done in the base class
  • All exception messages needed to be formatted the same way, with the number, reason and type. This get formmated message was done in the base class.

Our base exception class derives from ApplicationException. This may have been a mistake, there is a lot of discussion about problems with too much depth of inheritance. However, we have not had any problems with this.

One tip for the exam: Read the question very carefully. Good luck.

Shiraz Bhaiji
Thanks and Roger that !
IbrarMumtaz