简体   繁体   English

为什么Visual Studio会中断第三方库中引发和处理的异常?

[英]Why does Visual Studio break on Exceptions thrown and handled in a third party library?

Today I'm working on an Excel add-in written in C# and Visual Studio keeps on breaking on a CryptographicException (see screenshot). 今天,我正在研究用C#编写的Excel加载项,而Visual Studio一直在打破CryptographicException(请参见屏幕截图)。 It's not an exception handled by the code I'm developing, it's handled by the third party library I'm using. 这不是我正在开发的代码处理的异常,而是由我正在使用的第三方库处理的。 But VS still breaks on it. 但是VS仍然无法解决。 If I hit "Continue", the app will happily continue running even though the Exception isn't explicitly caught in the app anywhere. 如果我单击“继续”,则即使该异常未在任何地方明确捕获到应用程序中,该应用程序也将很乐意继续运行。 I don't have the source of the third party lib. 我没有第三方lib的来源。

I enabled "Just My Code" and removed the check from "CryptographicException" in the Exception dialog, but it keeps breaking on the exception. 我启用了“仅我的代码”,并从“异常”对话框中的“ CryptographicException”中删除了该检查,但是它不断破坏异常。 And I read the related questions I could find. 我阅读了我能找到的相关问题。 This question comes very close to what I'm asking but the OP still wants to see exceptions being thrown by third party libs whereas I only want to see the exceptions being unhandled in "my code". 这个问题非常接近我的要求,但是OP仍然希望看到第三方库抛出的异常,而我只希望看到在“我的代码”中未处理的异常。

So, is there a setting in Visual Studio that will allow me to do that? 那么,Visual Studio中是否有设置可以使我做到这一点?

例外

Turns out all I had to do was disable this setting: 原来我要做的就是禁用此设置:

Visual Studio调试设置

For those interested, it's under Tools -> Options -> Debugging -> General -> top of the page. 对于那些感兴趣的人,它位于工具->选项->调试->常规->页面顶部。

Just my code will not prevent Visual Studio from breaking when an exception in 3rd party library is thrown. 只是我的代码无法防止在抛出第三方库中的异常时Visual Studio中断。 See Just my code 只看我的代码

If an unhandled exception occurs in non-user code, the debugger breaks at the line in user code where the exception was generated. 如果非用户代码中发生未处理的异常,则调试器将在用户代码中生成异常的行处中断。 If first chance exceptions are enabled for the exception, the user-code line is highlighted in green. 如果为该异常启用了第一次机会异常,则用户代码行将以绿色突出显示。

The question is now, is it really unhandled (marked yellow) or is the line marked green -> handled. 现在的问题是,它是否真的未处理(标记为黄色),还是标记为绿色的行->已处理。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM