ErrorEventArgs クラス

Error イベントのデータを提供します。

この型のすべてのメンバの一覧については、ErrorEventArgs メンバ を参照してください。

System.Object
   System.EventArgs
      System.IO.ErrorEventArgs

Public Class ErrorEventArgs
   Inherits EventArgs
[C#]
public class ErrorEventArgs : EventArgs
[C++]
public __gc class ErrorEventArgs : public EventArgs
[JScript]
public class ErrorEventArgs extends EventArgs

スレッドセーフ

この型の public static (Visual Basicでは Shared) のすべてのメンバは、マルチスレッド操作で安全に使用できます。インスタンスのメンバの場合は、スレッドセーフであるとは限りません。

解説

ErrorEventArgsError イベントの原因となった Exception を含みます。このクラスは、例外を取得するための GetException メソッドを提供します。

使用例

[Visual Basic, C#, C++] ErrorEventArgs の新しいインスタンスを作成し、そのインスタンスを Exception を使用して初期化する例を次に示します。次に GetException を呼び出して Exception を取得し、エラー メッセージを表示します。このコードに関連付けられたフォームはありません。

 
Overloads Public Shared Sub Main(args() As String)
    ' Creates an exception with an error message.
    Dim myException As New Exception("This is an exception test")
    
    ' Creates an ErrorEventArgs with the exception.
    Dim myErrorEventArgs As New ErrorEventArgs(myException)
    
    ' Extracts the exception from the ErrorEventArgs and display it.
    Dim myReturnedException As Exception = myErrorEventArgs.GetException()
    MessageBox.Show(("The returned exception is: " & myReturnedException.Message))
End Sub 'Main

[C#] 
public static void Main(string[] args) {
    // Creates an exception with an error message.
    Exception myException= new Exception("This is an exception test");
 
    // Creates an ErrorEventArgs with the exception.
    ErrorEventArgs myErrorEventArgs = new ErrorEventArgs(myException);
 
    // Extracts the exception from the ErrorEventArgs and display it.
    Exception myReturnedException = myErrorEventArgs.GetException();
    MessageBox.Show("The returned exception is: " + myReturnedException.Message);
 }
    

[C++] 
int main() {
    // Creates an exception with an error message.
    Exception* myException= new Exception(S"This is an exception test");
 
    // Creates an ErrorEventArgs with the exception.
    ErrorEventArgs* myErrorEventArgs = new ErrorEventArgs(myException);
 
    // Extracts the exception from the ErrorEventArgs and display it.
    Exception* myReturnedException = myErrorEventArgs->GetException();
    MessageBox::Show(String::Concat( S"The returned exception is: ", myReturnedException->Message ));
}
   

[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

名前空間: System.IO

プラットフォーム: Windows NT Server 4.0, Windows NT Workstation 4.0, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ

アセンブリ: System (System.dll 内)

参照

ErrorEventArgs メンバ | System.IO 名前空間 | ErrorEventHandler | FileSystemWatcher | OnError