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 通常會遇到自動對應至 managed 對等的非受控 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)

從序列化 (Serialization) 資料,初始化 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()

在衍生類別中覆寫時,傳回一或多個後續的例外狀況的根本原因 ExceptionWhen 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()

傳回字串,其中包含錯誤的 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)

適用於

另請參閱