How to: Use the Exception Assistant

This topic applies to:

Edition

Visual Basic

C#

C++

Web Developer

Express

Topic applies Topic applies Topic does not apply Topic applies

Standard

Topic applies Topic applies Topic does not apply Topic applies

Pro and Team

Topic applies Topic applies Topic does not apply Topic applies

Table legend:

Topic applies

Applies

Topic does not apply

Does not apply

Topic applies but command hidden by default

Command or commands hidden by default.

The Exception Assistant, which appears whenever a run-time exception occurs, shows the type of exception, troubleshooting tips, and corrective actions. The Exception Assistant can also be used to see the details of an exception object.

An exception is an object that inherits from the Exception class. An exception is thrown by code when a problem occurs, and it is passed up the stack until the application handles it or the program fails.

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.

The following table lists and describes an exception object's properties. Depending on the type of exception, not all may appear.

Property

Description

Data

An IDictionary object that contains user-defined key/value pairs. The default is an empty collection.

FileName

Name of the file causing the exception.

FusionLog

Log file that describes why an assembly load failed.

HelpLink

Link to the help file associated with the exception.

HResult

Coded numerical value assigned to a specific exception.

InnerException

Exception instance that caused the current exception. It is sometimes useful to catch an exception thrown in a helper routine and throw a new exception more indicative of the error, thereby providing more information. In such cases, the InnerException property is set to the original exception.

Message

Message associated with the exception. This is displayed in the language specified by the CurrentUICulture property of the thread that throws the exception.

Source

Name of the application or object that caused the exception. If Source is not set, the name of the assembly where the exception originated is returned.

StackTrace

String representation of the method calls on the call stack at the time the current exception was thrown. The stack trace includes the source-file name and program line number if debugging information is available. StackTrace may not report as many method calls as expected, due to code transformations that occur during optimization. The stack trace is captured immediately before an exception is thrown.

TargetSite

Method that throws the current exception. If the method that throws the exception is not available and the stack trace is not a null reference (Nothing in Visual Basic), TargetSite obtains the method from the stack trace. If the stack trace is a null reference, TargetSite also returns a null reference.

To find out more about an exception object

  • Click View Details in the Actions pane. A dialog box appears showing the properties of the exception.

See Also

Tasks

How to: Map HRESULTs and Exceptions

How to: Correct Run-Time Errors with the Exception Assistant

How to: Check an Exception's Inner Exception

Concepts

Choosing When to Use Structured and Unstructured Exception Handling

Reference

Exception Assistant Dialog Box

Other Resources

Handling and Throwing Exceptions