visual-studio - 如何强制VS2019忽略 "try"部分内的异常

标签 visual-studio debugging exception try-catch visual-studio-2019

刚刚安装 VS2019 并注意到一件不舒服的事情:在调试中它在每个异常处停止(“下降”),即使在 try 部分。我怎样才能强制它忽略这些异常,转到 catch 并进一步工作?

在 Perry Qian-MSFT 的回答之后。现在,当我遇到未处理的异常时,我会看到这一点。

翻译:“应用程序处于暂停模式”。并且调用堆栈是空的。 After answer of Perry Qian-MSFT. Now I see this when I have UNHANDLED exception

最佳答案

How to force VS2019 ignore exceptions inside “try” section

首先,我同意dixv的观点并感谢他的帮助。

当前VS IDE可以根据需要忽略特定的异常。在Debug-->Windows-->Exception settings

您可以记录之前的异常名称并在其下搜索然后取消勾选。

enter image description here

注意

之后,请取消勾选Just My Code选项,否则异常仍可能中断。

工具-->选项-->调试-->常规-->只是我的代码

更新 1

如果您启用该功能并且还想在不破坏调试的情况下查看有关该异常的详细信息,您可以将这些代码添加到catch

 try
{

xxxxxxxxxxxxxxx

}
catch (Exception e) {

    Debug.WriteLine("=============================");
    Debug.WriteLine(e.Message);
    Debug.WriteLine(e.Source);
    Debug.WriteLine(e.StackTrace);
    Debug.WriteLine("============================="); 

}

它将在输出窗口中显示有关该异常的具体信息:

enter image description here

更多信息,您可以引用this issue .

更新 2

当你遇到这种情况时,你可以点击那个异常窗口的View Detail,它会调用Watch Widow,然后当你点击StackTrace时,它会向您显示相关的错误文件名和相关行。

enter image description here

希望对你有所帮助。

关于visual-studio - 如何强制VS2019忽略 "try"部分内的异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62138010/

相关文章:

linux - http ://ftp. gnu.org/gnu/gdb/gdb-7.9.tar.gz 中缺少 gdbserver 7.9

c - R包: breakpoint setup for C function with gdb in Debian (Testing)

c# - Debug.WriteLine(string, params object[]) 是一种方法,但像类型一样使用

java - 结果集关闭后,我收到“操作不允许”消息

c# - 在 Visual Studio 上并行执行 Python 脚本和 C# 脚本

visual-studio - 如何在 Azure 应用服务网站上获取 Debug.WriteLine 数据(或类似输出)?

java - 带有调度程序的 Spring Boot-BeanCreationNotAllowedException : Error creating bean with name 'entityManagerFactory' : Singleton bean creation not allowed

java - 长按 TextView 提示时应用程序崩溃

.net - 如何彻底清理我的 VS 2012 解决方案?

visual-studio - 调试时是否可以从目标目录启动外部程序?