VS2022 - 抛出异常时无法查看变量的值 - 局部变量和参数在“[Exception]”调用堆栈帧中不可用

Cal*_*nus 33 c# exception visual-studio-debugging visual-studio-2022

我抛出一个 InvalidOperationException (这应该很容易修复)。但是,当引发异常时,我无法在本地调试窗口中查看任何当前值。他们都传达了相同的信息:

Local variables and arguments are not available in '[Exception]' call stack frames. To obtain these, configure the debugger to stop when the exception is thrown and rerun the scenario.
Run Code Online (Sandbox Code Playgroud)

不确定为什么会发生这种情况(也许与异步有关?),但这是相对简单的代码,我应该能够看到这些变量的值。

Jin*_*SFT 23

您可以进入“调试”>“Windows”>“异常设置”并选择“System.InvalidOperationException”来解决该问题。 在此输入图像描述

  • 我在 .Net 7 应用程序中尝试过此操作,但仍然遇到相同的错误。我使用的是 VS 17.4.2。 (4认同)