无法在 .NET 中捕获的异常列表 [英] List of exceptions that CAN'T be caught in .NET

查看:24
本文介绍了无法在 .NET 中捕获的异常列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 .NET 中不能捕获的异常列表是什么?或者在哪里可以找到这样的列表?

What is the list of exceptions that CAN'T be caught in .NET? Or where can I find such a list?

推荐答案

唯一不能直接捕获的异常是(一个框架抛出)StackOverflowException.从逻辑上讲,这是有道理的,因为此时堆栈中没有空间来处理异常.来自文档:

The only exception that cannot be caught directly is (a framework thrown) StackOverflowException. This makes sense, logically, as you don't have the space in the stack to handle the exception at that point. From the docs:

从 .NET Framework 2.0 版开始,一个 StackOverflowException 对象不能被 try-catch 块捕获,相应的进程默认终止.

Starting with the .NET Framework version 2.0, a StackOverflowException object cannot be caught by a try-catch block and the corresponding process is terminated by default.

ThreadAbortException 可以被捕获,但总是会被捕获被重新加注,所以有独特的行为.来自文档:

ThreadAbortException can be caught, but will always get re-raised, so has unique behavior. From the docs:

ThreadAbortException 是一种特殊的异常,可以被捕获,但会在 catch 块的末尾自动再次引发.

ThreadAbortException is a special exception that can be caught, but it will automatically be raised again at the end of the catch block.

另请注意,某些 AccessViolationException 实例是损坏状态异常,默认情况下可能不会得到处理.这些可以处理,但需要通过属性进行额外处理.有关详细信息,请参阅处理损坏状态异常.

Also note that some AccessViolationException instances are corrupted state exceptions, and may not get handled by default. These can be handled, but require extra handling via attributes. For details, see Handling Corrupted State Exceptions.

这篇关于无法在 .NET 中捕获的异常列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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