Is there an easy way to set conditional breakpoints in Visual Studio?
If I want to hit a breakpoint only when the value of a variable becomes something, how can I do it?
Is there an easy way to set conditional breakpoints in Visual Studio?
If I want to hit a breakpoint only when the value of a variable becomes something, how can I do it?
Visual Studio provides lots of options for conditional breakpoints:
To set any of these you
These options are as follows:
foo == 8 or some other expression.Writing the actual condition can be the tricky part, so I tend to
Advantages of using the Immediate window:
This example breaks when the code is referring to a table with the name "Setting":
table.GetTableName().Contains("Setting")
Create a conditional function breakpoint:
In the Breakpoints window, click New to create a new breakpoint.
On the Function tab, type Reverse for Function. Type 1 for Line, type 1 for Character, and then set Language to Basic.
Click Condition and make sure that the Condition checkbox is selected. Type instr.length > 0 for Condition, make sure that the is true option is selected, and then click OK.
In the New Breakpoint dialog box, click OK.
On the Debug menu, click Start.