views:

1360

answers:

10

I am running Visual Studio 2008 with SP1. When I debug an application, it will skip over my break points.

For example, I have two lines of code, each call a method. I will put a break point on both lines. I will run it one time, and it ill stop at the first break point, but not the next one. I will run it again, and it ill hit the second one, not the first one.

I have tried to clean the solution and a rebuild.

I do have multiple projects in the solution.

+1  A: 

Try deleting your .SUO file for that project, and then rebuild.

George Stocker
A: 

Assuming symbol load is not an issue, you can put a BP on the method itself and verify that it indeed is getting called twice (by examining the call stack).

Mohit Chakraborty
+1  A: 

Ensure that you are building your application with the debug configuration.

Kibbee
And that your debug configuration has /Od as the optimization (which is almost always how it is, but sometimes it'll get changed by accident or whatever).
Michael Burr
A: 

If the breakpoint doesn't show up as a solid red bubble, but a red circle then it's disabled. If it's a red circle with a small yellow warning sign then the process(es) you're attached to hasn't loaded the symbols for that mode. Ensure you're trying to debug the correct type of code (Managed/ Native/ T-SQL/ Script).

Slace
+5  A: 

Symbol file incompatibility

It's possible that your symbol file (.pdb) is out of sync with your source code. A common symptom of this is:

  • Stopping at a breakpoint on a line of code
  • Stepping through the code
  • Seeing the debugging pointer stop at a blank line of code

When debugging, you should never see the debugging pointer stop on a blank line, and this would indicate that you have a symbol/source mismatch somewhere.

This sort of mismatch could also cause breakpoints to be skipped like you are seeing, but cleaning the solution generally fixes it (and it sounds like you have tried this already).

Build configuration

The other option (as suggested by others) is that you aren't building a Debug configuration. While it is possible to debug a Release build, the code is significantly optimised which can make the debugger act strangely, e.g.

  • Stepping through a conditional (i.e. if block) can make it appear that both the if and else cases are running
  • Some bits of code are completely optimised out, and you can't break on them

What are you trying to break on?

One other important thing to note is that breakpoints cannot be set on every line of code. For example, if your code only has a variable initialisation:

long numObjects;

the breakpoint will generally not be set properly (although it will usually move to the next line of "real" code). However, if your line of code initialises the variable:

long numObjects = 5;

the breakpoint can be set.

LeopardSkinPillBoxHat
A: 

I don't have an answer, but this issue has been bugging me as well for some time now. It seems to only happen on large-ish solutions (for instance, 25k+ lines of code in only one of the many solutions that make up the entire project, with dozens of references), and it's damn annoying: stepping through the code sometimes has the same effect as 'continue', so the debugger breaks at the next breakpoint, or sometimes doesn't break at all anymore (skips breakpoints) and continues until everything in the current block is executed.

It seems one of the suggested solutions, deleting the .suo file for the solution, has worked somewhat; I'm still getting these problems but a lot more rarely now. I can only assume some VS settings are responsible, but can't venture a guess as to which ones.

A: 

Is your app multithreaded? And do you run Resharper? I've just suddenly had strange debugging breakpoint problems with a multithreaded C# app in the last couple of weeks with 2008SP1 + R#4.5 EAP, which I've never seen before.

I did wonder if it was a recent Resharper issue, so strange and so unprecedented were the problems.

Will Dean
A: 

Did you ever find a good solution to this? I have encountered the same problem. My breakpoints seem to get hit randomly. Sometimes they break, sometimes they don't. Veerrry odd.

TahoePete
this might be the same problem i had. see my answer for link to the hotfix
mcintyre321
A: 

I had this problem and had to install a hotfix. See http://social.msdn.microsoft.com/Forums/en-US/vsdebug/thread/f3fcb4fb-8a08-4fa0-8d58-9ed6f3eb1193 for details

mcintyre321
A: 

I have been having the same problem, except without SP1 (which means that the hotfix doesn't apply to me). Tried the .suo file thing - no luck. It just started happening out of the blue - it was fine one day, and flaky the next. I almost always get it to stop at the very first breakpoint it reaches, but it rarely stops on any others after that. Can't step through any code, because it just continues. Have to keep moving my first breakpoint and re-running in order to see anything useful. Very frustrating.

If anyone has come across any other solutions, I'd love to hear them!

Laurie