I have been doing some reading lately about Exception Handling and the .Net Framework and this seems to have left me more confused then when I started.
In CLR via C# Fourth Addition I Read:
Also, the .NET Framework exception-handling mechanism is built using the Structured Exception Handling (SEH) mechanism offered by Microsoft Windows. SEH has been discussed in many resources, including my own book, Windows via C/C++, 5th ed. (Microsoft Press, 2007), which contains three chapters devoted to SEH.
Now, here is where my confusion starts. If the .Net Framework is built Using the SEH but is this only used for an unhandled exception or is it used right off the bat for all exception handling in .NET if so where does the CLR fit in, is taking Queues from SEH or is it acting on its own and using SEH if and when an unhandled exception Occurs?.
Second How does Context switching from the Kerrnal mode to User mode fit in? I know when a thread is created it has (From CLR via C#)
Thread environment block (TEB) The TEB is a block of memory allocated and initialized in user mode (address space that application code can quickly access). The TEB consumes 1 page of memory (4 KB on x86 and x64 CPUs, 8 KB on an IA64 CPU). The TEB contains the head of the thread’s exception-handling chain. Each try block that the thread enters inserts a node in the head of this chain; the node is removed from the chain when the thread exists in the try block. In addition, the TEB contains the thread’s thread-local storage data as well as some data structures for use by Graphics Device Interface (GDI) and OpenGL graphics.
AS well as the User Mode Stack and The Kernel mode stack. But Why would a context switch need to happen at any point as they have everything needed to process is on the same thread?