Interview questions

.Net -how exceptions are handled by the CLR

Next question>>           Learn .NET
.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.

Next question>>

Also read

ASP.NET exception handling technique

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?................ 

Explain how to Handle Exceptions in .NET 2.0.

The different methods of handling the exceptions are:...............

What are Custom Exceptions?

Custom Exceptions are user defined exceptions. There are exceptions other than the predefined ones which need to be taken care of.................

What is an Exception in .NET?

Exceptions are errors that occur during the runtime of a program................

.NET exception handling

Describe how exceptions are handled by the CLR.
How to throw a custom exception?................

Difference between System exceptions and Application exceptions in .NET.

Application exceptions can be user defined exceptions thrown by the application...................



Write your comment - Share Knowledge and Experience


 

 
Latest placement tests
Latest links
 
Latest MCQs
» General awareness - Banking » ASP.NET » PL/SQL » Mechanical Engineering
» IAS Prelims GS » Java » Programming Language » Electrical Engineering
» English » C++ » Software Engineering » Electronic Engineering
» Quantitative Aptitude » Oracle » English » Finance
Home | About us | Sitemap | Contact us | We are hiring