ErrorEventArgs Constructor (Exception)

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Initializes a new instance of the ErrorEventArgs class.

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

Public Sub New (
	exception As Exception
)

Parameters

exception
Type: System.Exception

An Exception that represents the error that occurred.

The following example creates a new instance of ErrorEventArgs and initializes it with an Exception. Then the example calls GetException to retrieve the Exception and display the error message. There is no form associated with this code.

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

.NET Framework
Available since 1.1
Return to top
Show: