SEHException 类

定义

表示结构化异常处理 (SEH) 错误。Represents structured exception handling (SEH) errors.

public ref class SEHException : Exception
public ref class SEHException : System::Runtime::InteropServices::ExternalException
public class SEHException : Exception
public class SEHException : System.Runtime.InteropServices.ExternalException
[System.Serializable]
public class SEHException : System.Runtime.InteropServices.ExternalException
[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
public class SEHException : System.Runtime.InteropServices.ExternalException
type SEHException = class
    inherit Exception
type SEHException = class
    inherit ExternalException
Public Class SEHException
Inherits Exception
Public Class SEHException
Inherits ExternalException
继承
SEHException
继承
属性

注解

SEHException 类处理从非托管代码引发的 SEH 错误,但尚未映射到另一个 .NET Framework 异常。The SEHException class handles SEH errors that are thrown from unmanaged code, but that have not been mapped to another .NET Framework exception. SEHException 类还对应于 HRESULT E_FAIL (0x80004005)。The SEHException class also corresponds to the HRESULT E_FAIL (0x80004005).

.NET Framework 通常会遇到自动映射到托管等效项的非托管 SEH 异常。The .NET Framework often encounters unmanaged SEH exceptions that are automatically mapped to managed equivalents. 存在两个常见的非托管 SEH 异常:There are two common unmanaged SEH exceptions:

  • STATUS_NO_MEMORY 异常会自动映射到 OutOfMemoryException 类。STATUS_NO_MEMORY exceptions are automatically mapped to the OutOfMemoryException class.

  • 将自动映射 STATUS_ACCESS_VIOLATION 异常,如下所示:STATUS_ACCESS_VIOLATION exceptions are automatically mapped as follows:

    • 如果应用 legacyNullReferencePolicy,则所有访问冲突都将映射到 NullReferenceException 类。If legacyNullReferencePolicy is applied, all access violations are mapped to the NullReferenceException class.

    • 如果尝试读取/写入的地址不在 JIT 编译的代码中,则会将异常映射到 AccessViolationException 类。If the address at which the read/write was attempted is not in JIT-compiled code, the exception is mapped to the AccessViolationException class.

    • 如果尝试读取/写入的地址在 JIT 编译的代码中,但它不在 OS Null 分区区中,则将异常映射到 AccessViolationException 类。If the address at which the read/write was attempted is in JIT-compiled code, but it is not in the OS Null partition area, the exception is mapped to the AccessViolationException class.

    • 如果没有 legacyNullReferencePolicy,并且尝试读取/写入的地址位于 JIT 编译的代码中,而在 OS Null 分区区中,则异常映射到 NullReferenceException 类。If there is no legacyNullReferencePolicy, and the address at which the read/write was attempted is in JIT-compiled code and in the OS Null partition area, the exception is mapped to the NullReferenceException class.

默认情况下,不会自动映射到特定异常的任何 SEH 异常都将映射到 SEHException 类。Any SEH exception that is not automatically mapped to a specific exception is mapped to the SEHException class by default.

请注意,SEHException 类不会导致调用C++非托管异常析构函数。Note that the SEHException class does not cause unmanaged C++ exception destructors to be called. 若要确保调用C++非托管异常析构函数,请在 catch 块中使用以下语法。To ensure that unmanaged C++ exception destructors are called, use the following syntax in the catch block.

Catch   
     ' Handle catch here.  
End Try  
catch  
{  
     // Handle catch here.  
}  
catch(…)  
{  
     // Handle catch here.  
}   

构造函数

SEHException()

初始化 SEHException 类的新实例。Initializes a new instance of the SEHException class.

SEHException(SerializationInfo, StreamingContext)

从序列化数据初始化 SEHException 类的新实例。Initializes a new instance of the SEHException class from serialization data.

SEHException(String)

用指定的消息初始化 SEHException 类的新实例。Initializes a new instance of the SEHException class with a specified message.

SEHException(String, Exception)

使用指定的错误消息和对作为此异常原因的内部异常的引用来初始化 SEHException 类的新实例。Initializes a new instance of the SEHException class with a specified error message and a reference to the inner exception that is the cause of this exception.

属性

Data

获取键/值对的集合,这些键/值对提供有关该异常的其他用户定义信息。Gets a collection of key/value pairs that provide additional user-defined information about the exception.

(继承自 Exception)
ErrorCode

获取错误的 HRESULTGets the HRESULT of the error.

(继承自 ExternalException)
HelpLink

获取或设置指向与此异常关联的帮助文件链接。Gets or sets a link to the help file associated with this exception.

(继承自 Exception)
HResult

获取或设置 HRESULT(一个分配给特定异常的编码数字值)。Gets or sets HRESULT, a coded numerical value that is assigned to a specific exception.

(继承自 Exception)
InnerException

获取导致当前异常的 Exception 实例。Gets the Exception instance that caused the current exception.

(继承自 Exception)
Message

获取描述当前异常的消息。Gets a message that describes the current exception.

(继承自 Exception)
Source

获取或设置导致错误的应用程序或对象的名称。Gets or sets the name of the application or the object that causes the error.

(继承自 Exception)
StackTrace

获取调用堆栈上的即时框架字符串表示形式。Gets a string representation of the immediate frames on the call stack.

(继承自 Exception)
TargetSite

获取引发当前异常的方法。Gets the method that throws the current exception.

(继承自 Exception)

方法

CanResume()

指示是否可以从异常中恢复,以及代码是否可以从引发异常的地方继续。Indicates whether the exception can be recovered from, and whether the code can continue from the point at which the exception was thrown.

Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(继承自 Object)
GetBaseException()

当在派生类中重写时,返回 Exception,它是一个或多个并发的异常的根本原因。When overridden in a derived class, returns the Exception that is the root cause of one or more subsequent exceptions.

(继承自 Exception)
GetHashCode()

作为默认哈希函数。Serves as the default hash function.

(继承自 Object)
GetObjectData(SerializationInfo, StreamingContext)

当在派生类中重写时,用关于异常的信息设置 SerializationInfoWhen overridden in a derived class, sets the SerializationInfo with information about the exception.

(继承自 Exception)
GetType()

获取当前实例的运行时类型。Gets the runtime type of the current instance.

(继承自 Exception)
MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(继承自 Object)
ToString()

创建并返回当前异常的字符串表示形式。Creates and returns a string representation of the current exception.

(继承自 Exception)
ToString()

返回一个字符串,该字符串包含错误的 HRESULT。Returns a string that contains the HRESULT of the error.

(继承自 ExternalException)

事件

SerializeObjectState

当异常被序列化用来创建包含有关该异常的徐列出数据的异常状态对象时会出现该问题。Occurs when an exception is serialized to create an exception state object that contains serialized data about the exception.

(继承自 Exception)

适用于

另请参阅