Tamer_Ahmed Posted July 9, 2004 Posted July 9, 2004 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 Quote
Administrators PlausiblyDamp Posted July 9, 2004 Administrators Posted July 9, 2004 (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 March 16, 2007 by PlausiblyDamp Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
FVCbr Posted July 10, 2004 Posted July 10, 2004 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 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.