SEHException SEHException SEHException SEHException Class

定义

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

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

注解

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. 类还HRESULT 对应E_FAIL于 (0x80004005)。 SEHExceptionThe 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.

    • 如果没有NullReferenceException , 并且读取/写入尝试的地址在 JIT 编译的代码中, 而在 OS Null 分区区中, 则异常映射到类。 legacyNullReferencePolicyIf 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.

有关详细信息, 请在 MSDN Library 中搜索 "非托管异常" 和 "结构化异常处理"。For more information, search on "unmanaged exceptions" and "Structured Exception Handling" in the MSDN Library.

请注意, 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() SEHException() SEHException()

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

SEHException(SerializationInfo, StreamingContext) SEHException(SerializationInfo, StreamingContext) SEHException(SerializationInfo, StreamingContext) SEHException(SerializationInfo, StreamingContext)

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

SEHException(String) SEHException(String) SEHException(String) SEHException(String)

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

SEHException(String, Exception) SEHException(String, Exception) SEHException(String, Exception) 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.

方法

CanResume() CanResume() CanResume() 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) Equals(Object) Equals(Object) Equals(Object)

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

(Inherited from Object)
GetBaseException() GetBaseException() GetBaseException() GetBaseException()

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

(Inherited from Exception)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

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

(Inherited from Object)
GetObjectData(SerializationInfo, StreamingContext) GetObjectData(SerializationInfo, StreamingContext) GetObjectData(SerializationInfo, StreamingContext) GetObjectData(SerializationInfo, StreamingContext)

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

(Inherited from Exception)
GetType() GetType() GetType() GetType()

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

(Inherited from Exception)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

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

(Inherited from Object)
ToString() ToString() ToString() ToString()

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

(Inherited from ExternalException)

属性

Data Data Data Data

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

(Inherited from Exception)
ErrorCode ErrorCode ErrorCode ErrorCode

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

(Inherited from ExternalException)
HelpLink HelpLink HelpLink HelpLink

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

(Inherited from Exception)
HResult HResult HResult HResult

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

(Inherited from Exception)
InnerException InnerException InnerException InnerException

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

(Inherited from Exception)
Message Message Message Message

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

(Inherited from Exception)
Source Source Source Source

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

(Inherited from Exception)
StackTrace StackTrace StackTrace StackTrace

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

(Inherited from Exception)
TargetSite TargetSite TargetSite TargetSite

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

(Inherited from Exception)

事件

SerializeObjectState SerializeObjectState SerializeObjectState SerializeObjectState

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

(Inherited from Exception)

适用于

另请参阅