Dela via


How to: Check an Exception's Inner Exception

In cases where an exception is thrown as a direct result of a previous exception, the InnerException property describes the original error. This information may allow you to handle the error more efficiently. If there is no original error, the value of InnerException will be a null reference or Nothing in Visual Basic. This property is read-only.

Note

  The options available in dialog boxes, and the names and locations of menu commands you see, might differ from what is described in Help depending on your active settings or edition. This Help page was written with General Development Settings in mind. To change your settings, choose Import and Export Settings on the Tools menu. For more information, see Visual Studio Settings.

To check an InnerException

  • Check the InnerException property of the exception to determine the cause of the original error.

    Try
        My.Computer.FileSystem.CopyFile("file1", "file2")
    Catch ex As System.IO.IOException
        MsgBox(ex.InnerException)
    End Try
    

See Also

Tasks

How to: Display an Exception's Message in Visual Basic

Troubleshooting Exception Handling

Reference

InnerException

Other Resources

Exception Handling Tasks