mscorlib(4.0.0.0) API with additions
System.Exception Class Reference

Represents errors that occur during application execution.To browse the .NET Framework source code for this type, see the Reference Source. More...

Inheritance diagram for System.Exception:
[legend]
Collaboration diagram for System.Exception:
[legend]

Public Member Functions

 Exception ()
 Initializes a new instance of the T:System.Exception class. More...
 
 Exception (string message)
 Initializes a new instance of the T:System.Exception class with a specified error message. More...
 
 Exception (string message, Exception innerException)
 Initializes a new instance of the T:System.Exception class with a specified error message and a reference to the inner exception that is the cause of this exception. More...
 
virtual Exception GetBaseException ()
 When overridden in a derived class, returns the T:System.Exception that is the root cause of one or more subsequent exceptions. More...
 
override string ToString ()
 Creates and returns a string representation of the current exception. More...
 
virtual void GetObjectData (SerializationInfo info, StreamingContext context)
 When overridden in a derived class, sets the T:System.Runtime.Serialization.SerializationInfo with information about the exception. More...
 
new Type GetType ()
 Gets the runtime type of the current instance. More...
 
- Public Member Functions inherited from System.Runtime.InteropServices._Exception
new bool Equals (object obj)
 Provides COM objects with version-independent access to the M:System.Object.Equals(System.Object) method. More...
 
new int GetHashCode ()
 Provides COM objects with version-independent access to the M:System.Object.GetHashCode method. More...
 

Protected Member Functions

 Exception (SerializationInfo info, StreamingContext context)
 Initializes a new instance of the T:System.Exception class with serialized data. More...
 

Properties

virtual string Message [get]
 Gets a message that describes the current exception. More...
 
virtual IDictionary Data [get]
 Gets a collection of key/value pairs that provide additional user-defined information about the exception. More...
 
Exception InnerException [get]
 Gets the T:System.Exception instance that caused the current exception. More...
 
MethodBase TargetSite [get]
 Gets the method that throws the current exception. More...
 
virtual string StackTrace [get]
 Gets a string representation of the immediate frames on the call stack. More...
 
virtual string HelpLink [get, set]
 Gets or sets a link to the help file associated with this exception. More...
 
virtual string Source [get, set]
 Gets or sets the name of the application or the object that causes the error. More...
 
int HResult [get, protected set]
 Gets or sets HRESULT, a coded numerical value that is assigned to a specific exception. More...
 
EventHandler< SafeSerializationEventArgsSerializeObjectState
 Occurs when an exception is serialized to create an exception state object that contains serialized data about the exception. More...
 
- Properties inherited from System.Runtime.InteropServices._Exception
string Message [get]
 Provides COM objects with version-independent access to the P:System.Exception.Message property. More...
 
string StackTrace [get]
 Provides COM objects with version-independent access to the P:System.Exception.StackTrace property. More...
 
string HelpLink [get, set]
 Provides COM objects with version-independent access to the P:System.Exception.HelpLink property. More...
 
string Source [get, set]
 Provides COM objects with version-independent access to the P:System.Exception.Source property. More...
 
Exception InnerException [get]
 Provides COM objects with version-independent access to the P:System.Exception.InnerException property. More...
 
MethodBase TargetSite [get]
 Provides COM objects with version-independent access to the P:System.Exception.TargetSite property. More...
 

Detailed Description

Represents errors that occur during application execution.To browse the .NET Framework source code for this type, see the Reference Source.

Definition at line 22 of file Exception.cs.

Constructor & Destructor Documentation

◆ Exception() [1/4]

System.Exception.Exception ( )

Initializes a new instance of the T:System.Exception class.

Definition at line 286 of file Exception.cs.

◆ Exception() [2/4]

System.Exception.Exception ( string  message)

Initializes a new instance of the T:System.Exception class with a specified error message.

Parameters
messageThe message that describes the error.

Definition at line 294 of file Exception.cs.

◆ Exception() [3/4]

System.Exception.Exception ( string  message,
Exception  innerException 
)

Initializes a new instance of the T:System.Exception class with a specified error message and a reference to the inner exception that is the cause of this exception.

Parameters
messageThe error message that explains the reason for the exception.
innerExceptionThe exception that is the cause of the current exception, or a null reference (Nothing in Visual Basic) if no inner exception is specified.

Definition at line 304 of file Exception.cs.

◆ Exception() [4/4]

System.Exception.Exception ( SerializationInfo  info,
StreamingContext  context 
)
protected

Initializes a new instance of the T:System.Exception class with serialized data.

Parameters
infoThe T:System.Runtime.Serialization.SerializationInfo that holds the serialized object data about the exception being thrown.
contextThe T:System.Runtime.Serialization.StreamingContext that contains contextual information about the source or destination.
Exceptions
T:System.ArgumentNullExceptionThe info parameter is null.
T:System.Runtime.Serialization.SerializationExceptionThe class name is null or P:System.Exception.HResult is zero (0).

Definition at line 317 of file Exception.cs.

Member Function Documentation

◆ GetBaseException()

virtual Exception System.Exception.GetBaseException ( )
virtual

When overridden in a derived class, returns the T:System.Exception that is the root cause of one or more subsequent exceptions.

Returns
The first exception thrown in a chain of exceptions. If the P:System.Exception.InnerException property of the current exception is a null reference (Nothing in Visual Basic), this property returns the current exception.

Implements System.Runtime.InteropServices._Exception.

Reimplemented in System.AggregateException.

Definition at line 395 of file Exception.cs.

◆ GetObjectData()

virtual void System.Exception.GetObjectData ( SerializationInfo  info,
StreamingContext  context 
)
virtual

When overridden in a derived class, sets the T:System.Runtime.Serialization.SerializationInfo with information about the exception.

Parameters
infoThe T:System.Runtime.Serialization.SerializationInfo that holds the serialized object data about the exception being thrown.
contextThe T:System.Runtime.Serialization.StreamingContext that contains contextual information about the source or destination.
Exceptions
T:System.ArgumentNullExceptionThe info parameter is a null reference (Nothing in Visual Basic).

Implements System.Runtime.InteropServices._Exception.

Reimplemented in System.Security.SecurityException, System.BadImageFormatException, System.IO.FileNotFoundException, System.AggregateException, System.IO.FileLoadException, System.Net.WebSockets.WebSocketException, System.Globalization.CultureNotFoundException, System.Net.Mail.SmtpException, System.TypeLoadException, System.Configuration.ConfigurationException, System.Net.WebException, System.ComponentModel.Win32Exception, System.Security.HostProtectionException, System.ArgumentOutOfRangeException, System.Xml.XmlException, System.ArgumentException, System.MissingMemberException, System.Diagnostics.Eventing.Reader.EventLogException, System.ObjectDisposedException, System.Xml.Schema.XmlSchemaException, System.Net.Mail.SmtpFailedRecipientsException, System.Reflection.ReflectionTypeLoadException, System.Net.Mail.SmtpFailedRecipientException, System.NotFiniteNumberException, System.Xml.Xsl.XsltException, System.ComponentModel.WarningException, System.ComponentModel.LicenseException, System.TypeInitializationException, System.Security.Principal.IdentityNotMappedException, System.Xml.XPath.XPathException, System.Security.AccessControl.PrivilegeNotHeldException, System.Net.CookieException, System.Net.ProtocolViolationException, System.Xml.Schema.XmlSchemaValidationException, System.Runtime.CompilerServices.RuntimeWrappedException, System.Xml.Xsl.XsltCompileException, and System.Xml.Schema.XmlSchemaInferenceException.

Definition at line 576 of file Exception.cs.

◆ GetType()

new Type System.Exception.GetType ( )

Gets the runtime type of the current instance.

Returns
A T:System.Type object that represents the exact runtime type of the current instance.

Implements System.Runtime.InteropServices._Exception.

Definition at line 753 of file Exception.cs.

◆ ToString()

override string System.Exception.ToString ( )

Creates and returns a string representation of the current exception.

Returns
A string representation of the current exception.

Implements System.Runtime.InteropServices._Exception.

Definition at line 474 of file Exception.cs.

Property Documentation

◆ Data

virtual IDictionary System.Exception.Data
get

Gets a collection of key/value pairs that provide additional user-defined information about the exception.

Returns
An object that implements the T:System.Collections.IDictionary interface and contains a collection of user-defined key/value pairs. The default is an empty collection.

Definition at line 115 of file Exception.cs.

◆ HelpLink

virtual string System.Exception.HelpLink
getset

Gets or sets a link to the help file associated with this exception.

Returns
The Uniform Resource Name (URN) or Uniform Resource Locator (URL).

Definition at line 174 of file Exception.cs.

◆ HResult

int System.Exception.HResult
getprotected set

Gets or sets HRESULT, a coded numerical value that is assigned to a specific exception.

Returns
The HRESULT value.

Definition at line 236 of file Exception.cs.

◆ InnerException

Exception System.Exception.InnerException
get

Gets the T:System.Exception instance that caused the current exception.

Returns
An object that describes the error that caused the current exception. The P:System.Exception.InnerException property returns the same value as was passed into the M:System.Exception.::ctor(System.String,System.Exception) constructor, or null if the inner exception value was not supplied to the constructor. This property is read-only.

Definition at line 139 of file Exception.cs.

◆ Message

virtual string System.Exception.Message
get

Gets a message that describes the current exception.

Returns
The error message that explains the reason for the exception, or an empty string ("").

Definition at line 95 of file Exception.cs.

◆ SerializeObjectState

EventHandler<SafeSerializationEventArgs> System.Exception.SerializeObjectState
addremoveprotected

Occurs when an exception is serialized to create an exception state object that contains serialized data about the exception.

Definition at line 260 of file Exception.cs.

◆ Source

virtual string System.Exception.Source
getset

Gets or sets the name of the application or the object that causes the error.

Returns
The name of the application or the object that causes the error.
Exceptions
T:System.ArgumentExceptionThe object must be a runtime N:System.Reflection object

Definition at line 192 of file Exception.cs.

◆ StackTrace

virtual string System.Exception.StackTrace
get

Gets a string representation of the immediate frames on the call stack.

Returns
A string that describes the immediate frames of the call stack.

Definition at line 162 of file Exception.cs.

◆ TargetSite

MethodBase System.Exception.TargetSite
get

Gets the method that throws the current exception.

Returns
The T:System.Reflection.MethodBase that threw the current exception.

Definition at line 150 of file Exception.cs.


The documentation for this class was generated from the following file: