Question

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.

Was it helpful?

Solution

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.

OTHER TIPS

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

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

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

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

I have had the same problem with MS Visual Studio 2008 SP1. PDB files matched executables files, so it was not a problem.

The problem was Visual Assist. I turned it off in "Tools | Add-in manager" and after that there have been no problems with skipping breakpoints. So turn off any add-ins that you have in Visual Studio and install latest SP (it is SP1 right now).

In addition to the above methods, I've also come across another couple of circumstances where breakpoints aren't hit:

  • The source is from a different directory tree. This can happen if you've renamed the directory, as paths are hardcoded into the pdb files. This caught me out when I had a trunk and branch dir that I swapped around and VS opened files in the other directory.
  • If the exe is still running in the background, which can sometimes happen if the app doesn't exit cleanly or somehow mspdbsrv.exe is still attached to it, so check your process list. Restart Visual Studio often fixes this.

I had the same problem in VS 2008 and tried everything spending about 1 hour but didn't help.

Finally tried running VS without administrator right and then Clean Solution->Rebuild Solution and worked fine.

Don't like VS on Win 7

I had the same issue, and installing VS 2010 SP1 resolved this. I had a side-effect of breaking Intellisense in SQL 2008, which you can read about here: Sql Server 2008 R2 Management Studio - no Intellisense

Also, removing run in compatibility mode for VS executable solves the problem.

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

I guess you changed your project to optimized code, so, no debug information is available (including the ability to use breakpoints).

To correct this: open your project, click on menu->project->(your_project) properties..., click on compile tab, click on advanced compile options, then: - unselect "enable optimizations" - in generate debug info list, choose "full". - Click OK, close and save everything. Should work now.

MFR>

For web sites, this can occur if a separate instance of MSVS was runnning the same web site.

Just stop the original instance or stop IIS Express.

MSVS seemingly starts the 2nd web site without complaining about the pre-existing one that was running on the same port. Possibly the page shown in the browser is really the 1st web site.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top