All professional-grade programs need to handle unexpected conditions. In programming languages before Microsoft .NET, this was often called error handling. Unexpected conditions generated error codes, which were trapped by programming logic that took appropriate action.
The common language runtime in .NET does not generate error codes. When an unexpected condition occurs, the CLR creates a special object called an exception. This object contains properties and methods that describe the unexpected condition in detail and provide various items of useful information about what went wrong.
Because the .NET Framework deals with exceptions instead of errors, the term error handling is seldom used in the .NET world. Instead, the term exception handling is preferred. This term refers to the techniques used in .NET to detect exceptions and take appropriate action.
This chapter covers how exception handling works in Visual Basic 2008. It discusses the common language runtime (CLR) exception handler in detail and the programming methods that are most efficient in catching errors. Specifically, it covers the following:
A very brief overview of error handling in Visual Basic 6 (VB6), for those just moving to .NET
The general principles behind exception handling
Finally structure, the
Exit Try statement, and nested
The exception object's methods and properties
Capabilities in Visual Studio for working with exceptions
Error and ...