ErrorEventArgs.GetException Methode

Definitie

Hiermee wordt de Exception fout opgehaald die is opgetreden.

public:
 virtual Exception ^ GetException();
public virtual Exception GetException();
abstract member GetException : unit -> Exception
override this.GetException : unit -> Exception
Public Overridable Function GetException () As Exception

Retouren

Een Exception die de fout aangeeft die is opgetreden.

Voorbeelden

In het volgende voorbeeld wordt een nieuw exemplaar gemaakt van ErrorEventArgs en geïnitialiseerd met een Exception. Vervolgens wordt het voorbeeld aanroepen GetException om het Exception foutbericht op te halen en weer te geven. Er is geen formulier gekoppeld aan deze code.


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

Van toepassing op