.Net - Explain how exceptions are handled by the common language
runtime in .NET. - June 03, 2009 at 11:00 AM by Shuchi Gauri
Explain how exceptions are handled by the common language runtime in .NET.
The CLR uses a technique generally referred to as a two-pass exception review
process. What this means is that the CLR will process an exception in two
passes. In the first pass, the CLR will determine if there is a handler for the
exception. This is done by reviewing the entries in the SEH table; specifically
it looks at the Try Offset and Try Length flags to see if the exception
occurred within a guarded block, and if so, whether the Flags entry dictates
that a handler exists for this type of occurrence. Let's assume that the CLR
did find a handler during the first pass. At that point the CLR begins a second
pass of the SEH table during which it will work through the execution phase of
the exception management process. So we can divide the two passes into a
discovery pass, in which we determine whether there is a handler in this method
context to handle the exception; and an execution pass, in which we actually
execute the handler and any special rules.
When code throws an exception, the CLR looks up the call stack looking for a
catch filter to handle the exception. When it finds the relevant catch block,
before executing the code, it will execute all code in all finally blocks -
starting from the try block that threw the exception and stopping with the
catch filter that matches the exception. when the CLR encounters an exception
for a method it will use the descriptors in the SEH table to determine how to
handle the exception, which code block is affected, and what handler should be
invoked.
Also read
Define Exception handling in ASP.NET.
What are the ways of handling exceptions in ASP.NET?
Explain Try/catch block method of exception handling.
Define Error Events.
Define Custom Error Pages.
Why is exception handling important to an application?
When can you use tracing with exception handling?................
The different methods of handling the exceptions are:...............
Custom Exceptions are user defined exceptions. There are exceptions other than
the predefined ones which need to be taken care of.................
Exceptions are errors that occur during the runtime of a program................
Describe how exceptions are handled by the CLR.
How to throw a custom exception?................
Application exceptions can be user defined exceptions thrown by the
application...................
|