Freigeben über


ErrorEventArgs.GetException-Methode

Ruft die Exception ab, die den aufgetretenen Fehler darstellt.

Namespace: System.IO
Assembly: System (in system.dll)

Syntax

'Declaration
Public Overridable Function GetException As Exception
'Usage
Dim instance As ErrorEventArgs
Dim returnValue As Exception

returnValue = instance.GetException
public virtual Exception GetException ()
public:
virtual Exception^ GetException ()
public Exception GetException ()
public function GetException () : Exception

Rückgabewert

Eine Exception, die den aufgetretenen Fehler darstellt.

Beispiel

Im folgenden Beispiel wird eine neue Instanz von ErrorEventArgs erstellt und mit einer Exception initialisiert. Anschließend wird im Beispiel GetException aufgerufen, um die Exception abzurufen und die Fehlermeldung anzuzeigen. Diesem Code ist kein Formular zugeordnet.

Public Shared Sub Main()
    '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
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);
}
int main()
{
   
   //Creates an exception with an error message.
   Exception^ myException = gcnew Exception( "This is an exception test" );
   
   //Creates an ErrorEventArgs with the exception.
   ErrorEventArgs^ myErrorEventArgs = gcnew ErrorEventArgs( myException );
   
   //Extracts the exception from the ErrorEventArgs and display it.
   Exception^ myReturnedException = myErrorEventArgs->GetException();
   MessageBox::Show( String::Concat( "The returned exception is: ", myReturnedException->Message ) );
}
public static void main(String[] args)
{
    //Creates an exception with an error message.
    System.Exception myException = 
        new System.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.
    System.Exception myReturnedException = myErrorEventArgs.GetException();

    MessageBox.Show("The returned exception is: " 
        + myReturnedException.get_Message());
} //main

Plattformen

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

Siehe auch

Referenz

ErrorEventArgs-Klasse
ErrorEventArgs-Member
System.IO-Namespace