Exception - This is the base class of all exceptions. Do not derive user-defined custom exceptions from this class.
SystemException - This class is provided as a means to differentiate between exceptions defined by the system versus exceptions defined by applications. Do not derive from this.
ApplicationException - Derive user defined exceptions/custom exceptions from this class.
I agree with you but I has a warning then following when I enabled Code Analysis
CA1058 : Microsoft.Design : Change TestException's base type so that it no longer extends System.ApplicationException. This base exception type does not provide any additional value for framework classes. Extend System.Exception or an existing unsealed exception type instead. Do not create a new exception base type unless there is specific value in enabling the creation of a catch handler for an entire class of exceptions.
I hasn't a warning When I changed to inherit from exception
Go to GotDotNet.com and search for "ApplicationException FxCop", you will find a number of posts regarding this, including some responses from Microsoft.
Yea, the Microsoft Guidelines are old and wrong on this situation.
It is now recommended that you inherit from Exception. SystemException and ApplicationException were supposed to categorize system exceptions from application exceptions. But it was long decided ago that it was of no benefit to derive from ApplicationException (it offers no new properties/methods).
So the recommendation from FxCop is the correct one.
Exception Usage
Tom2
SystemException - This class is provided as a means to differentiate between exceptions defined by the system versus exceptions defined by applications. Do not derive from this.
ApplicationException - Derive user defined exceptions/custom exceptions from this class.
Regards,
Vikram
Snarf99
CA1058 : Microsoft.Design : Change TestException's base type so that it no longer extends System.ApplicationException. This base exception type does not provide any additional value for framework classes. Extend System.Exception or an existing unsealed exception type instead. Do not create a new exception base type unless there is specific value in enabling the creation of a catch handler for an entire class of exceptions.
I hasn't a warning When I changed to inherit from exception
Why
Angedinoir
Vikram
Go to GotDotNet.com and search for "ApplicationException FxCop", you will find a number of posts regarding this, including some responses from Microsoft.
I will post a suggestion for this to be updated.
blaise
Thanks for the info. The Beta documentation is also still saying the old stuff:
http://msdn2.microsoft.com/library/ww58ded5(en-us,vs.80).aspx
Do you have any link which describes this new guideline
Thanks,
Vikram
Scott Oveson
It is now recommended that you inherit from Exception. SystemException and ApplicationException were supposed to categorize system exceptions from application exceptions. But it was long decided ago that it was of no benefit to derive from ApplicationException (it offers no new properties/methods).
So the recommendation from FxCop is the correct one.