Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio is missing/moving my breakpoints

Tags:

The problem is that when I place a breakpoint and debug/run, the breakpoint moves by itself.

Before/whilst coding:

enter image description here

After clicking run/breakpoint hit:

enter image description here

Breakpoints typically work ok for me, but it seems that they sometimes randomly play up. I first had this ages ago with a VB project, and in the end, I bypassed the problem by removing the breakpoint and adding it somewhere else where it was still useful.

Whilst I could probably do the same again, and this is only the second time it has happened (that I remember), I don't really want to have to and would like to know what is actually wrong.

I have read through many similar questions here, but I cannot see an exact match and the answers do not help. I have tried - building, rebuilding, closing/reopening and cleaning.

I only provided a picture of the bit of code where it occurs, if you need anything else, please let me know.

like image 649
Wil Avatar asked Feb 15 '11 23:02

Wil


People also ask

How do I enable breakpoints in Visual Studio?

To set a breakpoint in source code, click in the far left margin next to a line of code. You can also select the line and press F9, select Debug > Toggle Breakpoint, or right-click and select Breakpoint > Insert breakpoint. The breakpoint appears as a red dot in the left margin.

Why is my breakpoint not working?

If a source file has changed and the source no longer matches the code you're debugging, the debugger won't set breakpoints in the code by default. Normally, this problem happens when a source file is changed, but the source code wasn't rebuilt. To fix this issue, rebuild the project.


2 Answers

It's because the debugger isn't able to break at that point. For example, the debugger can't break on auto-implemented properties, or at the header of a method; instead, it breaks at the first line of the method.

like image 117
user541686 Avatar answered Dec 17 '22 14:12

user541686


Also check to see if you had set the breakpoints in one mode (Debug) but are now in a different mode (like Release). This caused me some momentary angst.

like image 28
Mike Burger Avatar answered Dec 17 '22 13:12

Mike Burger