Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

ErrorEventArgs Constructor

Initializes a new instance of the ErrorEventArgs class.

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

public ErrorEventArgs (
	Exception exception
)
public ErrorEventArgs (
	Exception exception
)
public function ErrorEventArgs (
	exception : Exception
)

Parameters

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 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 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

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

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.