C#中的异常如何工作(在幕后) [英] How do exceptions work (behind the scenes) in C#

查看:75
本文介绍了C#中的异常如何工作(在幕后)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

异常如何工作(在场景),但对于 C#

我知道,当出现异常时,必须执行以下步骤

I know that the steps below have to be performed when an exception is thrown.


  1. 查找最近的异常类型处理程序;

  2. 将堆栈展开到处理程序级别;

  3. 调用处理程序;

  4. 查找并最终调用每个 块。

  1. Find the nearest handler for the exception type;
  2. Unwind the stack up to the handler level;
  3. Call the handler;
  4. Find and call every finally blocks.

.NET如何处理这些操作? 当前处理程序的映射如何工作?在try / catch块中发出多少代码?

How does .NET handles these operations? How does the mapping for the "current" handlers work? How much code is emitted in a try/catch block? And in a throw block?

推荐答案

请阅读Christopher Brumme的文章;它提供了有关CLR异常处理中幕后发生情况的非常详细的解释:

Read Christopher Brumme's article; it gives a very detailed explanation of what happens behind the scenes in CLR exception handling:

http://blogs.msdn.com/b/cbrumme/archive/2003/10/01/51524.aspx

这篇关于C#中的异常如何工作(在幕后)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆