ErrorEventArgs.GetException Methode
Definition
Wichtig
Einige Informationen beziehen sich auf Vorabversionen, die vor dem Release ggf. grundlegend überarbeitet werden. Microsoft übernimmt hinsichtlich der hier bereitgestellten Informationen keine Gewährleistungen, seien sie ausdrücklich oder konkludent.
Ruft den Exception Fehler ab, der aufgetreten ist.
public:
virtual Exception ^ GetException();
public virtual Exception GetException();
abstract member GetException : unit -> Exception
override this.GetException : unit -> Exception
Public Overridable Function GetException () As Exception
Gibt zurück
Ein Exception Wert, der den aufgetretenen Fehler darstellt.
Beispiele
Im folgenden Beispiel wird eine neue Instanz erstellt ErrorEventArgs und mit einer Exceptioninitialisiert. Anschließend ruft das Beispiel auf GetException , um die Exception Fehlermeldung abzurufen und anzuzeigen. Diesem Code ist kein Formular zugeordnet.
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);
}
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