.net - 异常处理上下文切换和SEH

标签 .net exception

我最近一直在阅读一些有关异常处理和 .Net Framework 的内容,这似乎让我比刚开始时更加困惑。

在 CLR 中通过 C# 第四个添加我读到:

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.

现在,我的困惑就从这里开始了。如果 .Net 框架是使用 SEH 构建的,但这仅用于未处理的异常,还是立即用于 .NET 中的所有异常处理(如果是)CLR 适合在哪里,是从 SEH 获取队列还是它独立运作并使用 SEH如果并且当 unhandled exception Occurs? .

第二,从内核模式到用户模式的上下文切换是如何适应的?我知道当创建一个线程时它有(从 CLR 通过 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以及用户模式堆栈和内核模式堆栈。但是,为什么需要在任何时候进行上下文切换,因为处理所需的所有内容都在同一个线程上?

最佳答案

这里有关于 CLR 如何处理异常的非常详细的解释(我相信是一位 CLR 架构师写的):http://blogs.msdn.com/b/cbrumme/archive/2003/10/01/51524.aspx

关于.net - 异常处理上下文切换和SEH,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4277661/

相关文章:

从另一个 AppDomain 访问时,c# 脚本有错误的数据

java - 仅第一次捕获异常,第二次捕获异常

c# - 如何通过 C# WebClient 发送 HTTP DELETE 请求?

c# - 如何使用 C# 使用 MsTest 对属性进行单元测试?

java ZonedDateTime 毫秒部分解析错误

c# - .Net Winforms 中未捕获设计时异常

java - 异常无法处理?

javascript异常对象格式

c# - 表单不响应 KeyDown 事件

.net - 温莎城堡内部构造函数/类