Conditions when finally does not execute in a .net try..finally block(当 finally 不在 .net try..finally 块中执行时的条件)
问题描述
基本上我听说某些条件会导致 .net 吹过 finally 块.有谁知道这些条件是什么?
Basically I've heard that certain conditions will cause .net to blow past the finally block. Does anyone know what those conditions are?
推荐答案
两种可能:
- StackOverflowException
- ExecutionEngineException
当存在 StackOverflowException
时,finally 块将不会被执行,因为堆栈上没有空间可以执行更多代码.当存在 ExecutionEngineException
时也不会调用它,这可能是由于调用 Environment.FailFast()
引起的.
The finally block will not be executed when there's a StackOverflowException
since there's no room on the stack to even execute any more code. It will also not be called when there's an ExecutionEngineException
, which may arise from a call to Environment.FailFast()
.
这篇关于当 finally 不在 .net try..finally 块中执行时的条件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:当 finally 不在 .net try..finally 块中执行时的条件


基础教程推荐
- 从 VS 2017 .NET Core 项目的发布目录中排除文件 2022-01-01
- 如何动态获取文本框中datagridview列的总和 2022-01-01
- JSON.NET 中基于属性的类型解析 2022-01-01
- 将事件 TextChanged 分配给表单中的所有文本框 2022-01-01
- 全局 ASAX - 获取服务器名称 2022-01-01
- 错误“此流不支持搜索操作"在 C# 中 2022-01-01
- 首先创建代码,多对多,关联表中的附加字段 2022-01-01
- 在 VS2010 中的 Post Build 事件中将 bin 文件复制到物 2022-01-01
- 经典 Asp 中的 ResolveUrl/Url.Content 等效项 2022-01-01
- 是否可以在 asp classic 和 asp.net 之间共享会话状态 2022-01-01