Can I programmatically force the debugger into single-step mode?

I’ve written some code that is crashing when run with a multiple objects reference unclear error and I don’t understand why there are multiple objects in scope.

Is there a way to pause the app using #if debugbuild so that I can single-step through the malfunctional code and see exactly what is happening?

Are you looking for finer control than just setting a breakpoint?

Yes -

#if DebugBuild Break #endif

If (my_conditions_are_met) then
  break
end if

I hate break because you can’t turn it off while running. I prefer something like

X = X

If need be you can set a breakpoint there or turn it off during runtime, but I’m still unsure of the OP knows about breakpoints.

Ken Tekinay is correct. I stepped away from using RB for a while thanks to CS classes teaching other languages and forgot about the breakpoints! How do I set/remove one?

Click to the left of a line of code and red dot will appear.

In the margin.

I use to add a Beep and set the breakpoint there. You may use something else, then use the MenuItem to remove all breaks (Clear All or Show All and… Turn On)…

Yes, there is a MenuItem to add a Breakpoint ! We (I) learn things every days…

if you want a conditionnal break, then using “break” with a check before is the only way I know.

Or, like Kem suggests, instead of “break” use a statement that has no real effect then place a breakpoint on it. This has the virtue of allowing you do disable once you hit it the first time, but still otherwise keep the debug session going without having to break each time your condition is hit.

I’ll often write code that looks like this:

for index as integer = 0 to whatever
  #if DebugBuild then
    if someCondition then
      index = index // A place to break
    end if
  #endif
  // More code
next