System Namespace


.NET Framework Class Library
ApplicationException Class

The exception that is thrown when a non-fatal application error occurs.

Namespace:  System
Assembly:  mscorlib (in mscorlib.dll)
Syntax

Visual Basic (Declaration)
<SerializableAttribute> _
<ComVisibleAttribute(True)> _
Public Class ApplicationException _
    Inherits Exception
Visual Basic (Usage)
Dim instance As ApplicationException
C#
[SerializableAttribute]
[ComVisibleAttribute(true)]
public class ApplicationException : Exception
Visual C++
[SerializableAttribute]
[ComVisibleAttribute(true)]
public ref class ApplicationException : public Exception
JScript
public class ApplicationException extends Exception
Remarks

User applications, not the common language runtime, throw custom exceptions derived from the ApplicationException class. The ApplicationException class differentiates between exceptions defined by applications versus exceptions defined by the system.

If you are designing an application that needs to create its own exceptions, you are advised to derive custom exceptions from the Exception class. It was originally thought that custom exceptions should derive from the ApplicationException class; however in practice this has not been found to add significant value. For more information, see Best Practices for Handling Exceptions.

ApplicationException uses the HRESULT COR_E_APPLICATION, which has the value 0x80131600.

For a list of initial property values for an instance of ApplicationException, see the ApplicationException constructors.

Inheritance Hierarchy

System..::.Object
  System..::.Exception
    System..::.ApplicationException
      Microsoft.JScript..::.BreakOutOfFinally
      Microsoft.JScript..::.ContinueOutOfFinally
      Microsoft.JScript..::.JScriptException
      Microsoft.JScript..::.NoContextException
      Microsoft.JScript..::.ReturnOutOfFinally
      System.Reflection..::.InvalidFilterCriteriaException
      System.Reflection..::.TargetException
      System.Reflection..::.TargetInvocationException
      System.Reflection..::.TargetParameterCountException
      System.Threading..::.WaitHandleCannotBeOpenedException
Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Platforms

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98, Windows CE, Windows Mobile for Smartphone, Windows Mobile for Pocket PC, Xbox 360, Zune

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Version Information

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 3.5, 2.0, 1.0

XNA Framework

Supported in: 3.0, 2.0, 1.0
See Also

Reference

Other Resources

Tags :


Community Content

_FRED_
ApplicationException considered useless
Do not forget about Framework Design Guidelines: http://blogs.msdn.com/kcwalina/archive/2006/06/23/644822.aspx
Tags : exception

mageer
ApplicationException is useful
I would like to respectfully disagree with the previous post. While Mr. Richter is right, there are some problems in the .NET Framework back in June 2006 (do we know if it has been fixed in 3.5?) I still think it is useful to separate your exceptions by System and Application.

We have coding best practices around using ApplicationException and it makes it easier to separate our exceptions from the SystemExceptions. I will admit, however, we do occasionally catch some exceptions that are not from our application.

Karel Zikmund
Example of ApplicationException usage

using System;
namespace ShopEngine
{
public sealed class Product
{
private String name;
public String Name
{
get { return name; }
set
{
if (value != null) name = value;
else throw new UndefinedNameException();
}
}

public sealed class UndefinedNameException : ApplicationException
{
public UndefinedNameException() : base("Name cannot be null") {}
}

} // end of class Product
}


Page view tracker