Visual Studio Misplaces My Breakpoints

boB Gage 11 Reputation points
2022-07-19T23:34:18.197+00:00

I'm having severe difficulties debugging my code because Visual Studio is breaking in locations that do not match my breakpoints. Often this looks like VS just zipping right past my breakpoints, in other cases (as pictured), we hit the breakpoint but the call stack shows that we are not in the location marked in the source.

222483-vs-wrong-breakpoint-location.jpg

Referring to the picture, note:

  1. The breakpoint is at the top of the function addIcon(...) as indicated by the yellow highlight and arrow. That is the location I want the breakpoint.
  2. The call stack shows that the function urlHtml(...) is actually executing. That function can be seen in the source window and precedes addIcon(...)
  3. The "Locals" window shows variables from the urlHtml function, not the variables from the function with the breakpoint, addIcon()

Not visible:
4) Single stepping forward visually looks like it's jumping lines in addIcon(), sometimes moving 2-3 lines at a step; likely due to the differences in command length at a machine code level. Continuing to single-step will "exit" the addIcon() function midway through the source, as the source does not contain the commands being executed.
5) When addIcon() executes, no breakpoint is hit -- it just runs, incorrectly, because that's where the bug I need to fix is located.

I have cleaned & rebuilt the solution. Exited & restarted Visual Studio. Changed browsers (Edge & Chrome, IE not supported). Even rebooted the machine, but no luck.

Developer technologies | Visual Studio | Debugging
Developer technologies | Visual Studio | Other
{count} votes

2 answers

Sort by: Most helpful
  1. Tianyu Sun-MSFT 34,441 Reputation points Microsoft External Staff
    2022-07-20T08:31:36.617+00:00

    Hi @boB Gage ,

    Welcome to Microsoft Q&A forum.

    Is your project an ASP .NET project? If so, may I ask if you have selected this option(project properties > Web > Debuggers > ASP .NET)?

    Best Regards,
    Tianyu

    • If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
      Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

  2. boB Gage 11 Reputation points
    2022-07-30T01:08:05.647+00:00

    Interesting ... last week I put in an answer to this issue, but it seems to have disappeared before I could accept my own answer.

    Anyways, to repeat:

    I dug around on the web and found a different, but similar issue that was solved by RENAMING the page (and backing object) in Visual Studio. I did that to my page, and viola -- all my breakpoints were back where they belong and working properly again.

    So yeah -- no explanation I can think of that doesn't involve bugs in environment code, but renaming COVID-19.aspx to CovidEmpPage.aspx along with the VB and JS files before the clean build finally did the trick. Clean build alone didn't do it.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.