InnerException Property

[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]

Gets the Exception instance that caused the current exception.

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

public:
property Exception^ InnerException {
	Exception^ get ();
}

Property Value

Type: System..::..Exception
An instance of Exception that describes the error that caused the current exception. The InnerException property returns the same value as was passed into the constructor, or a null reference (Nothing in Visual Basic) if the inner exception value was not supplied to the constructor. This property is read-only.

When an exception X is thrown as a direct result of a previous exception Y, the InnerException property of X should contain a reference to Y.

Use the InnerException property to obtain the set of exceptions that led to the current exception.

You can create a new exception that catches an earlier exception. The code that handles the second exception can make use of the additional information from the earlier exception to handle the error more appropriately.

Show: