我正在尝试使用此表达式设置条件断点:
new System.Diagnostics.StakTrace().ToString().Contains("SetupValidity")
但它总是出错:
The following breakpoint cannot be set:
(redacted) when 'new System.Diagnostics.StakTrace().ToString().Contains("SetupValidity")' is true
The condition for a breakpoint failed to execute.
The condition was 'new System.Diagnostics.StakTrace().ToString().Contains("SetupValidity")'.
The error returned was 'Evaluation of method System.Diagnostics.StackTrace.ToString requires calling method
System.Reflection.MethodBase.get_MethodImplementationFlags, which cannot be called in this context.'
四处搜索,我发现了两个建议:
Tools -> Options -> Debugging -> Use Managed Compatibility Mode
Enable native code debugging
尝试分别启用这些功能,同时...没有变化。
工具:
.NET Core 3.1
Microsoft Visual Studio Community 2019 16.8.5
我该如何解决这个问题?
答案 0 :(得分:1)
错误消息清楚地表明您无法“修复”此问题;如果您确实需要中断条件,则需要更改代码,并在常规编译代码中评估 new System.Diagnostics.StakTrace().ToString()
,然后执行您选择的任何测试/中断。