Search code examples
c#visual-studiodebuggingbreakpoints

Visual Studio is missing/moving my breakpoints


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.


Solution

  • 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.