Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Breakpoint not fully highlighted when debugging

I'm having a weird problem where breakpoints that are currently hit are not fully highlighted, which causes them to be only partially evaluated. See image below. The statement the debugger is on returns true. However, the debugger does not go past 'products' and thus it goes to the end of the if statement. It can happen to any line of code regardless of length. Also, the point at which the highlighting drops off is random, sometimes it will only highlight the first letter.

Example: enter image description here

I use Attach to Process (on all w3wp.exe instances) for this project. When not debugging the whole line is highlighted as it should be.

I have tried the following:

  • Clean & ReBuild Project
  • Deleting bin & obj folders and restarting VS
  • Deleting all breakpoints and resetting one or two
  • Restarting computer
  • Deleting .SUO file
  • Trying the solutions in this somewhat-similar topic

I'm not sure what I'm missing here.

like image 259
Paul Avatar asked Oct 23 '15 18:10

Paul


People also ask

How do I fix breakpoint 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 are my breakpoints 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.

What is a breakpoint in debugging?

About Breakpoints A breakpoint is a location in your script or keyword test where you want the script or test to pause during execution. Once execution is paused, you can check the state of the test, its output and its variables. Breakpoints only function if the Enable Debugging item of the Debug toolbar is checked.


1 Answers

This happens when Visual Studio is stepping through compiled code that does not match the source code displayed in the IDE. Among other things, the generated pdb tells VS how long an individual line of code is in order to properly highlight it on a breakpoint; the "incomplete highlighting" indicates that VS is executing a line of code with a different length than the actual line indicated. You need to completely clean and rebuild everything. I know you indicated that you tried that, but something is persisting or not being built correctly.

You can also try going to Debug > Options and Settings, checking "Require source files to exactly match the original version", and building/running again. This should be additional confirmation that there is a mismatch between what you're looking at and what's being compiled.

like image 104
pymaxion Avatar answered Nov 14 '22 22:11

pymaxion