Mink Machine

Breakpoint issues in Visual Studio

When debugging large projects in Visual Studio, I’ve sometimes noticed that the IDE has suddenly inserted breakpoints at random places in the code. This can be largely confusing, since they does not appear in the list of breakpoints and won’t go away by a simple “clear bookmarks” command. There are several causes and solutions to this issue. Some are common sense while others border on the edge of voodoo.

Breakpoints are stored in the .suo (solution user options) file, created by Visual Studio when you create a new solution. This file is stored in binary format and it’s also a hidden file (to hide from the two percent who doesn’t enable “show hidden files”). The easiest route is to delete this file, since Visual Studio will create a new one for you, but this approach feels like wiping bread crumbs under your carpet.

First thing to check is the state of the breakpoints. Are they solid red, or marked with a question mark or similar? Does the execution stop on all breakpoints? If yes to both questions, read on. If not, the error is most likely caused by unreachable code.

A common problem that may give strange behavior is when user files are placed under solution control, resulting in debug symbols getting out of sync. Files that should not be under source control are .suo, .pdb, .csproj.user, .projdata and other files that hold local data.

Breakpoints “Gotta catch em all.”

Cache is another classic source of strange errors. You may have to delete the C:\Documents and Settings\<user>\VSWebCache folder (don’t forget to close Visual Studio first).

Also have a look at C:\Documents and Settings\<user>\Local Settings\Application Data\assembly and see if there is a sub directory called “dl2”. If there is, and you find copies of your working assemblies there, you can probably delete them since it is an issue with the shadowcopy.

If you’re felling lucky, you may have a look in the registry at HKCR\CLSID\{0A29FF9E-7F9C-4437-8B11-F424491E3931}\ InprocServer32 (aspnet_wp). If it’s empty, then all managed breakpoints are broken.

The breakpoint might not have been bound to the correct instance. Check the Breakpoint window in Visual Studio to see if the breakpoint has a “+” sign. By clicking this sign, you can see if multiple instances are tied to your breakpoint.

If multiple source files use the same name but is located in different paths, the debugger could be using the wrong one. This could be solved by setting the Source File Paths under Solution Properties.

Hope this helps and good luck with your breakpoints!


No comments yet.

Leave a reply

Your email address will not be published. Required fields are marked *