Mink Machine

Breakpoint issues in Visual Studio.NET

When debugging large projects in VisualStudio.NET, 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.

(And as always, don’t try this at home unless you know what you’re doing. I don’t take any responsibility for any damage you might inflict on yourself. In fact, I don’t even hear you. Sha-la-la…)

Breakpoints are stored in the .suo (solution user options) file, created by VS when you create a new solution. This file is stored in binary format, so the structure is not worth mentioning any further. it is also a hidden file, to hide from the 2 % who doesn’t check “show hidden files”. The easiest route is to delete this file, since VS will create a new one for you, but this approach is 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 VS 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 birth to 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.

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 VS first). Also have a look at C:\Documents and Settings\<user>\Local Settings\Application Data\assembly and see if there is a “dl2” subdir. 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 VS 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.


No comments yet.

Post a comment

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

Featured stories

Good morning Montenegro

"One would almost think that all this secrecy was made on purpose to keep the hordes of tourists away. Let them all perish in the crowds of Dubrovnik while the people of Montenegro can enjoy their beautiful country on their own. Or something like that."

Exploring Chernobyl

"But unlike the movie Chernobyl Diaries, we didn’t find anybody there. Nature had reclaimed the area and the silence was deafening."

Greetings from Moldova

"But Chisinau is an unexpected gem in the wilderness. Even though Moldova is one of the poorest countries in Europe, the capital has its fair share of impressive buildings and post-Soviet architecture."

On the Trans-Siberian

"Since the toilets were locked during the seven hour stop, we had to bribe the provodnitsas to use the facilities. Then came the Mongols."

The streets of Paris

"One of the advantages of repeated visits to a place is the leisure pace of awe and discovery while drifting slowly down the worn streets of the French capital."

The dark days of Sarajevo

"The city survived on the edge of annihilation and has started to recover, but the stone walls still seem to cry out in lament of all the horrible things they have seen."