visual-studiodebuggingvisual-studio-2022tracepoint

Adding condition for comparing Guid on breakpoint using Visual Studio 2022


I am still learning debugging tools on Visual Studio 2022. How do you use the conditional option on breakpoint to compare values with Guid.

I want to use the capabilities of debugging tools in order to minimize writing temporary codes for debugging and it may be useful for debugging loops.

I tried this, but did not work.

Photo: Conditional Breakpoint

At the end, I just write if statement code then breakpoint it.


Solution

  • I tried this, but did not work

    Do you mean the breakpoint you have set Conditions not hit ?

    If so, please add the variable id to Watch Window to check the value has updated to the new. From looking at your screenshot, looks like the variable id has not updated to entity.Id, but you have set a condition for it.

    id.ToString().ToUpper() =="A79xxx"
    

    Actually, at this point in time, the value of id is null because the assignment statement has not yet been executed.

    null == "A79xxx"
    

    You need set breakpoint conditions after the variable has been assigned.

    For example

    enter image description here