Поделиться через


How to: Check an Exception's Inner Exception (Visual Basic)

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

Your computer might show different names or locations for some of the Visual Studio user interface elements in the following instructions. The Visual Studio edition that you have and the settings that you use determine these elements. 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 (Visual Basic)

Reference

InnerException

Other Resources

Exception Handling Tasks (Visual Basic)