[英]Visual Studio 2015 using Linq in conditional breakpoint
Is it possible to use Linq within a conditional breakpoint?是否可以在条件断点内使用 Linq?
I'm attempting to break when the following condition is true:当以下条件为真时,我试图中断:
parentElement.ChildElements.Any(c => c.Id == 1)
When ever the debugger is hit the following error message is displayed当调试器被击中时,会显示以下错误消息
The debugger is unable to evaluate this expression.调试器无法计算此表达式。
I have tried the following condition in case the issue was related to using .Any()
如果问题与使用.Any()
有关,我已经尝试了以下条件
parentElement.ChildElements.Where(c => c.Id == 1).Count() > 0
This resulted in the same error as above being displayed.这导致显示与上面相同的错误。
I know a work around would be the following code我知道解决方法是以下代码
#if DEBUG
if(parentElement.ChildElements.Any(c => c.Id == 1))
{
System.Diagnostics.Debugger.Break();
}
#endif
However, I would ideally not like to make code changes to place a debugger.但是,理想情况下,我不想更改代码来放置调试器。
This issue was caused by the Use Managed Compatibility Mode
option not being enabled within Visual Studio.此问题是由未在 Visual Studio 中启用的Use Managed Compatibility Mode
选项引起的。
Once this option was checked the breakpoint performed as expected.选中此选项后,断点将按预期执行。
See this answer for how to enable this option within Visual Studio.请参阅此答案以了解如何在 Visual Studio 中启用此选项。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.