SystemException 建構函式

定義

初始化 SystemException 類別的新執行個體。Initializes a new instance of the SystemException class.

多載

SystemException()

初始化 SystemException 類別的新執行個體。Initializes a new instance of the SystemException class.

SystemException(String)

使用指定的錯誤訊息,初始化 SystemException 類別的新執行個體。Initializes a new instance of the SystemException class with a specified error message.

SystemException(SerializationInfo, StreamingContext)

初始化具有序列化資料之 SystemException 類別的新執行個體。Initializes a new instance of the SystemException class with serialized data.

SystemException(String, Exception)

使用指定的錯誤訊息以及造成此例外狀況的內部例外狀況的參考,初始化 SystemException 類別的新執行個體。Initializes a new instance of the SystemException class with a specified error message and a reference to the inner exception that is the cause of this exception.

SystemException()

初始化 SystemException 類別的新執行個體。Initializes a new instance of the SystemException class.

public:
 SystemException();
public SystemException ();
Public Sub New ()

備註

此函式會將新實例的 Message 屬性初始化為描述錯誤的系統提供訊息,例如「發生系統錯誤」。This constructor initializes the Message property of the new instance to a system-supplied message that describes the error, such as "A system error has occurred." 這個訊息會考量目前系統的文化特性。This message takes into account the current system culture.

下表顯示 SystemException 執行個體的初始屬性值。The following table shows the initial property values for an instance of SystemException.

屬性Property Value
InnerException null 參考 (在 Visual Basic 中為 Nothing)。A null reference (Nothing in Visual Basic).
Message 當地語系化的錯誤訊息字串。The localized error message string.

SystemException(String)

使用指定的錯誤訊息,初始化 SystemException 類別的新執行個體。Initializes a new instance of the SystemException class with a specified error message.

public:
 SystemException(System::String ^ message);
public SystemException (string message);
new SystemException : string -> SystemException
Public Sub New (message As String)

參數

message
String

描述錯誤的訊息。The message that describes the error.

備註

使用者應該可以理解 message 參數的內容。The content of the message parameter should be understandable to the user. 需要此建構函式的呼叫者,才能確保此字串已針對目前的系統文化特性進行當地語系化。The caller of this constructor is required to ensure that this string has been localized for the current system culture.

下表顯示 SystemException 執行個體的初始屬性值。The following table shows the initial property values for an instance of SystemException.

屬性Property Value
InnerException null 參考 (在 Visual Basic 中為 Nothing)。A null reference (Nothing in Visual Basic).
Message 錯誤訊息字串。The error message string.

SystemException(SerializationInfo, StreamingContext)

初始化具有序列化資料之 SystemException 類別的新執行個體。Initializes a new instance of the SystemException class with serialized data.

protected:
 SystemException(System::Runtime::Serialization::SerializationInfo ^ info, System::Runtime::Serialization::StreamingContext context);
protected SystemException (System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context);
new SystemException : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> SystemException
Protected Sub New (info As SerializationInfo, context As StreamingContext)

參數

info
SerializationInfo

保存序列化物件資料的物件。The object that holds the serialized object data.

context
StreamingContext

有關來源或目的地的內容資訊。The contextual information about the source or destination.

備註

這個建構函式是在還原序列化期間呼叫,以便重新組成透過資料流傳輸的例外狀況物件。This constructor is called during deserialization to reconstitute the exception object transmitted over a stream. 如需詳細資訊,請參閱 < XML 和 SOAP 序列化For more information, see XML and SOAP Serialization.

另請參閱

SystemException(String, Exception)

使用指定的錯誤訊息以及造成此例外狀況的內部例外狀況的參考,初始化 SystemException 類別的新執行個體。Initializes a new instance of the SystemException class with a specified error message and a reference to the inner exception that is the cause of this exception.

public:
 SystemException(System::String ^ message, Exception ^ innerException);
public SystemException (string message, Exception innerException);
new SystemException : string * Exception -> SystemException
Public Sub New (message As String, innerException As Exception)

參數

message
String

解釋例外狀況原因的錯誤訊息。The error message that explains the reason for the exception.

innerException
Exception

造成目前例外狀況的例外狀況。The exception that is the cause of the current exception. 如果 innerException 參數不是 Null 參考 (在 Visual Basic 中為 Nothing),則會在處理內部例外的 catch 區塊中引發目前的例外狀況。If the innerException parameter is not a null reference (Nothing in Visual Basic), the current exception is raised in a catch block that handles the inner exception.

備註

直接因為前一個例外狀況而擲回的例外狀況可能包含對 InnerException 屬性中前一個例外狀況的參考。An exception that is thrown as a direct result of a previous exception can include a reference to the previous exception in the InnerException property. InnerException 屬性會傳回與傳入建構函式中相同的值;如果 Nothing 屬性不提供內部例外值給建構函式,則傳回 null 參考 (在 Visual Basic 中為 InnerException)。The InnerException property returns the same value that is passed into the constructor, or a null reference (Nothing in Visual Basic) if the InnerException property does not supply the inner exception value to the constructor.

下表顯示 SystemException 執行個體的初始屬性值。The following table shows the initial property values for an instance of SystemException.

屬性Property Value
InnerException 內部例外狀況參考。The inner exception reference.
Message 錯誤訊息字串。The error message string.

另請參閱

適用於