什么是“第一次机会例外”?

发布于 2024-07-14 14:35:56 字数 75 浏览 5 评论 0原文

到底什么是第一次机会例外? 它是如何以及在哪里起源于 .NET 程序的? 为什么它被称为这个奇特的名字(我们谈论的是什么“机会”)?

What exactly is a first chance exception? How and where does it originate in a .NET program? And why is it called by that peculiar name (what 'chance' are we talking about)?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

岁吢 2024-07-21 14:35:56

这是一个调试概念。 基本上,异常首先被抛出到调试器,然后到实际程序,如果不处理它,它会第二次被抛出到调试器,给你一个 >有机会在应用程序本身之前和之后在 IDE 中使用它执行某些操作。 这似乎是 Microsoft Visual Studio 的发明。

It's a debugging concept. Basically exceptions are thrown to the debugger first and then to the actual program where if it isn't handled it gets thrown to the debugger a second time, giving you a chance to do something with it in your IDE before and after the application itself. This appears to be a Microsoft Visual Studio invention.

月亮邮递员 2024-07-21 14:35:56

当抛出异常时,会引发第一次机会异常通知。 第二次机会通知是当它未被捕获时。 (机会——就像闯入调试器中代码的机会)。

第一次和第二次机会异常处理

First chance exception notifications are raised when an exception is thrown. Second chance notifications are when it is not caught. (Chance – as in opportunity to break into the code in the debugger).

First and second chance exception handling

难得心□动 2024-07-21 14:35:56

我刚刚开始使用调试器并遇到了这个。 在我的研究中,我发现了 MSDN 博客文章 什么是第一次机会异常? 这为我解决了这个问题。

对我来说,这篇博文的最大收获是它指的是向调试器发出的通知,而不是我的代码必须需要处理的内容,最重要的是,

“第一次机会异常消息通常并不意味着存在
代码中存在问题。”

I just started using the debugger and ran into this. In my research, I found the MSDN blog post What is a First Chance Exception? that cleared it up for me.

The big takeaways from the blog post for me are that it refers to notification to the debugger, and not something my code would necessarily need to handle, and most importantly,

"First chance exception messages most often do not mean there is a
problem in the code."

ぇ气 2024-07-21 14:35:56

从开发人员的角度来看,它更多地涉及第二次机会异常,因为这意味着它没有在代码中处理; 因此应用程序将停止。

第一次机会可能有很多,但从开发的角度来看,更值得关注的是第二次机会,因为它会导致应用程序崩溃。

From a developer's perspective, it's more concerning a second-chance exception, because it would mean it was not handled in code; therefore the application would stop.

First chance could be many of them, but the ones to concern about more, again, from a development perspective, are second chance, because it would lead to an application crash.

眼泪也成诗 2024-07-21 14:35:56

调试应用程序时,每当遇到异常时,调试器都会收到通知。 此时,应用程序被挂起,调试器决定如何处理异常。 第一次通过此机制称为“第一次机会”异常。

根据调试器的配置,它将恢复应用程序并传递异常,或者使应用程序挂起并进入调试模式。 如果应用程序处理了异常,它将继续正常运行。

第一次机会异常消息通常并不意味着代码中存在问题。 对于优雅地处理异常的应用程序/组件,第一次机会异常消息让开发人员知道遇到了异常情况并已得到处理。

When an application is being debugged, the debugger gets notified whenever an exception is encountered. At this point, the application is suspended and the debugger decides how to handle the exception. The first pass through this mechanism is called a "first chance" exception.

Depending on the debugger's configuration, it will either resume the application and pass the exception on or it will leave the application suspended and enter debug mode. If the application handles the exception, it continues to run normally.

First chance exception messages most often do not mean there is a problem in the code. For applications / components which handle exceptions gracefully, first chance exception messages let the developer know that an exceptional situation was encountered and was handled.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文