Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

hi what's the different between system.exception and system.applicationexception

i know that it's derive from system.exception but why if i want to make my own exception calss i inherit it from applicationexception not exception class

  • Administrators
Posted (edited)
Too be honest there is probably no real reason to inherit from ApplicationException - I believe the original idea was user exceptions derived from ApplicationException where as Framework errors would inherit from System.Exception. then again MS didn't follow this themselves either ;) Some of the FCL exceptions derive from Exception some from System.Exception and some from ApplicationException. Edited by PlausiblyDamp

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Posted

According to the .NET Framework Standard Library Annotated Reference, you should always derive from System.Exception. And they have a valid point. it's just that it is another layer in the hierarchy that doesn't add any real information or utility itself.

 

Here's what Brad Adams posted about it:

 

The only reason that you would derive from ApplicationException is if you wanted to catch all ApplicationException derived exceptions for some reason:

 

// This is bad

try

{

// may throw ApplicationException derived exceptions

}

catch ( ApplicationException)

{

// handle all application specific exceptions

}

 

The problem with this is that it is always a bad idea to catch at this high a level. In other words, it is almost never useful to handle all exceptions defined by your application in the same way. It tends to hide bugs. Specific exceptions should be caught instead.

 

If you want more info go to : http://blogs.msdn.com/brada/archive/2004/03/25/96251.aspx

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...