Conditional breakpoint not working
Asked Answered
L

3

6

Conditional Dialog

The above code has a conditional breakpoint set at its bottom line in yellow followed by the Breakpoint Settings dialog which should work with: item.Value == "aday"

However I get the below error, I have searched online for this and can't find any reason why this should fail. Im using VS 2015 Pro.

enter image description here

EDIT- Thank you for pointing out the obvious error on my part, I do normally code in C#. But now using a single '=' I get this??????? I assume that I it equates to an assignment, and adding parenthesis didn't help either?

enter image description here

Languish answered 7/4, 2016 at 14:41 Comment(5)
Use .Equals() instead of =/==.Rexfourd
One additional hint: conditional breakpoints tend to have a bad performance. Use If item.Value = "aday" Then Debugger.Break() instead like shown hereOlav
@Rexfourd I got an error with .equals I'm afraid, not sure but possibly because Im in strict mode. If I add a code breakpoint like my below answer then it works fine, thank you very muchLanguish
@AndrewDay were you able to solve this ? I am using C# and I get your second error => "The breakpoint condition must evaluate to a boolean operation". My condition is "myVar != null" and it fails :(Theocrasy
@Theocrasy My solution is at the bottom, I have marked it as correct now. ThanksLanguish
L
4
If item.Value.Equals("aday") Then 'Temp If please remove
                    Debugger.Break()
                end if

Works in strict mode.

Languish answered 7/4, 2016 at 15:40 Comment(0)
T
13

Just tested with a sample VB.NET project.
The problem is the ==. This is C# syntax but since you have a VB.NET application you should use a single equal

item.Value = "aday" 

(I have always something new to learn from SO)

Translocation answered 7/4, 2016 at 14:46 Comment(0)
L
4
If item.Value.Equals("aday") Then 'Temp If please remove
                    Debugger.Break()
                end if

Works in strict mode.

Languish answered 7/4, 2016 at 15:40 Comment(0)
P
1

I am using the C# in Visual Studio 2017.

After search in an hour, conclusion was:

rewrite the conditional expression from:

item.Value == "aday"

to:

item != null && item.Value == "aday"

MAKE SURE item was not null. so that you can refer to field of value with item.Value

Puglia answered 14/5, 2018 at 15:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.