Reputation: 19396
I have this code:
foreach(MyType iterator in myList)
{
Object myObject = iterator.MyProperty;
}
Well, really this is not my code, is an example, what I want to do is set a breakpoint into the foreach and check if the iterator.MyProperty is null.
In the condition of my breakpoint I set:
iterator.MyProperty == null
But I get an error because the breakpoint can't evaluate the condition.
I am using VS2015 community.
Thank you so much.
Upvotes: 2
Views: 185
Reputation: 9570
Your debugger can read and test values of variables. However it can't execute your code.
If MyProperty
was a simple variable in the iterator
object it certainly would be properly handled by a debugger's breakpoint condition expression. But it is probably a property with some getter function, so the debugger would have to jump into your code in a breakpoint handler to obtain the desired value — and it simply is not allowed to do that.
Upvotes: 3
Reputation: 172578
You can try like this:
using System.Diagnostics;
........
foreach(MyType iterator in myList)
{
if (iterator.MyProperty == null)
{
Debugger.Break();
}
Object myObject = iterator.MyProperty;
}
You may also refer: http://weblog.west-wind.com/posts/2013/Nov/21/Visual-Studio-2013-Could-not-evaluate-Expression-Debugger-Abnormality
Upvotes: 2