Click to Rate and Give Feedback
MSDN
MSDN Library
.NET Development
.NET Framework 3.5
System Namespace
Collapse All/Expand All Collapse All
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
.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)
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

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.

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

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.

.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
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
ApplicationException considered useless      _FRED_   |   Edit   |   Show History
Do not forget about Framework Design Guidelines: http://blogs.msdn.com/kcwalina/archive/2006/06/23/644822.aspx
Flag as ContentBug
ApplicationException is useful      mageer   |   Edit   |   Show History
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.
Example of ApplicationException usage      Ackiel ... Karel Zikmund   |   Edit   |   Show History

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
}

Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement | Site Feedback
Page view tracker