Common Exception Model

Common Exception Model

.NET offers a common exception model. Exception handling is implemented within the CLR and is not specific to a managed language. Each managed language exposes exception handling using language-specific syntax. The uniform exception model contributes to language independence, which is an important tenet of .NET. In addition, exceptions raised in one managed language can be caught in a different managed language. Prior to .NET, there were competing models for error handling: Microsoft Visual Basic 6.0, Win32 SDK, MFC, COM, and more. In a component-driven architecture, this disparity contributed to complexity and potential product instability. In .NET, exception handling between disparate components is consistent, simple, and stable.

As part of the common exception model, .NET advocates structured exception handling, which is essentially the try and catch statements. C-based and Java developers are probably familiar with structured exception handling. For Visual Basic developers, this is a seismic shift from unstructured exception handling. The unstructured model, such as on error goto and on error resume, is thankfully now obsolete.