user838133
user838133

Reputation: 83

Visual Studio 2010: breakpoint hits on wrong file

I don't have much hope anyone will be able to answer this, but I'll try anyway:

In Visual Studio 2010, when I click to set a breakpoint in any file, another file opens and the breakpoint gets set to the same line number in that file instead.

To illustrate:

  1. I open foo.cs
  2. I click to add a breakpoint on line 100
  3. VS opens bar.cs and sets a breakpoint on (the wrong) line 100
  4. I spew curses at Microsoft

As always, any help would be appreciated.

Upvotes: 4

Views: 761

Answers (1)

Vincent Léger
Vincent Léger

Reputation: 11

You are not alone!

I have the exact same issue with Visual Studio 2015 and it's very annoying. In my experience, it only happens when 2 different projects (in the same solution) both contain a file with the same name.

It's related to the different PDB files and the order in which they are loaded. If the debugger can find a file with matching name, it doesn't seems to care whether it's found in the good PDB or not.

Sadly enough, this has been documented for a while on MSDN (msdn.microsoft.com/en-us/library/h6aesyw2%28v=vs.100%29.aspx) and it still is not resolved.

Microsoft's workaround is to write the full file path when adding breakpoints, but I don't find this to be a viable solution as it drastically slows down the debugging process.

Here are other "solutions" I have found:

  1. Renaming file names (so they become unique);
  2. Deleting .SUO file for the solution seem to work in certain cases (doesn't work for me);
  3. Deleting the PDB files for the "wrong" project (hopefully you are not trying to debug both simultaneously);
  4. Changing options for the "wrong" project so it doesn't generate/read PDB files at runtime.

Hope this helps!

Upvotes: 1

Related Questions