This documentation is archived and is not being maintained.

Exceptions in Components

Visual Studio .NET 2003

If you design and run components, they will occasionally cause or encounter errors. When a client program calls a method of your component, any exceptions you throw and/or decide not to handle will be passed along to the client program.

Throwing exceptions to the client is appropriate behavior for components. A well-behaved component does not intrude on the client application's user interface by displaying message boxes containing error text.

Users of an application may be unaware that your component is part of the application they are using. Seeing error messages from a program unknown to them will not help users solve the problem.

The following topics discuss the strategies and mechanics of returning error information to the client application, for the application's developer to deal with as she chooses.

In This Section

Best Practices for Throwing Exceptions from Components
Describes when to throw exceptions, when not to throw exceptions, what kind of exceptions to throw, and what information to include with the exception.
Throwing Exceptions from Components
Details the mechanics of throwing exceptions.
Recommendations on Handling Exceptions in Components
Provides recommendations regarding what to do when an exception occurs in your component class code.
Handling Exceptions in Your Component
Describes the mechanics of handling exceptions and including additional information when rethrowing exceptions.

Related Sections

Exception Handling
Provides background on how exceptions are handled in Visual Basic.
Exception Handling Statements
Provides background on how exceptions are handled in Visual C#.
Show: