This documentation is archived and is not being maintained.

Exception Handling Fundamentals

The common language runtime supports an exception handling model based on the concepts of exception objects and protected blocks of code. The runtime creates an object to represent an exception when it occurs. You can also create your own exception classes by deriving classes from the appropriate base exception.

All languages that use the runtime handle exceptions in a similar manner. Each language uses a form of try/catch/finally structured exception handling. This section provides several examples of basic exception handling.

How to: Use the Try/Catch Block to Catch Exceptions

Describes how to use the try/catch block to handle exceptions.

How to: Use Specific Exceptions in a Catch Block

Describes how to catch specific exceptions.

How to: Explicitly Throw Exceptions

Describes how to throw exceptions and how to catch exceptions and then throw them again.

How to: Create User-Defined Exceptions

Describes how to create your own exception classes.

Using User-Filtered Handlers

Describes how to set up filtered exceptions.

How to: Use a Finally Block

Explains how to use the finally statement in an exception block.

Handling and Throwing Exceptions

Provides an overview of common language runtime exceptions.

Exception Class and Properties

Describes the elements of an exception object.