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 块中执行时的条件
基础教程推荐
- rabbitmq 的 REST API 2022-01-01
- 将 Office 安装到 Windows 容器 (servercore:ltsc2019) 失败,错误代码为 17002 2022-01-01
- 如何激活MC67中的红灯 2022-01-01
- 如何在 IDE 中获取 Xamarin Studio C# 输出? 2022-01-01
- 为什么Flurl.Http DownloadFileAsync/Http客户端GetAsync需要 2022-09-30
- SSE 浮点算术是否可重现? 2022-01-01
- 将 XML 转换为通用列表 2022-01-01
- 有没有办法忽略 2GB 文件上传的 maxRequestLength 限制? 2022-01-01
- MS Visual Studio .NET 的替代品 2022-01-01
- c# Math.Sqrt 实现 2022-01-01