Inheriting from System.Exception or System.ApplicationException?

Posted in .NET quirks at Monday, 17 December 2007 18:02 GMT Standard Time
Yes, there is a bit of confusion about this (also read this post).

I understand that the right way to create your application specific exceptions classes is to inherit from Exception class:
public class MyCustomEx : System.Exception{
   //class implementation
And if in any case you have to throw a general application exception that has not specific type, throw a System.ApplicationException:
throw new System.ApplicationException("Error retrieving data. The web service may be down");

AddThis Social Bookmark Button