views:

1828

answers:

5

Hi everyone

I'm really hoping someone can help me out with this one. When debugging in Visual Studio, sometimes I add a breakpoint but it's hollow and VS says "The breakpoint will not currently be hit. The source code is different from the original version." Obviously this prevents me being able to debug.

What on earth does the message mean? What original version? If I've just opened up the solution and not made any changes whatsoever to the code, how can there be an 'original version'?

The appearance of this problem just seems totally arbitrary. It's just Visual Studio going 'Na na na na na, I'm not going to debug for you today'.

Can anyone give any advice?

Ta

David

+1  A: 

As lexu said:

"recompile/build the project before adding the break-point"

Paulo Santos
+2  A: 

Did you ever do this?

http://stackoverflow.com/questions/596142/would-you-like-to-continue-and-run-the-last-successful-build

If you ticked the box and pressed "Yes" you will get the last successful build running even though your project does not compile. This means that whenever you set a breakpoint, you will get that error.

Try changing this value:

Tools
    Options
        Projects and Solutions
            Build and Run
                On Run, when build or deployment errors occur: Do not Launch
Codesleuth
I don't *think* I had done that. Thanks for the link though. It gave me an insight into what that prompt means!
David
Visual Studio had this option for decades now (at least VS98 had it). I never understood why anyone would want to run the last successful build. After all, if that was what I wanted, I would have launched it directly, since I couldn't debug anyway. Do not Launch would have been a more sensible default.
OregonGhost
I've used it a few times to run the project (for whatever reason, like just to show someone else) while I'm still in the middle of writing code that won't compile. *Sometimes* it's handy. Personally, I leave it disabled.
Codesleuth
+1  A: 

This happen often also if you are using a file references to binaries (instead of project references to code in your project), and the compiled binary that you are referencing falls out of sync with the corresponding source code on your machine. This can happen because you downloaded a new version of the binary from source control without the new source code that went with it, or you have a few versions of the binary on your machine and are referencing an old copy, etc. If this is indeed the problem, it's a good reason to use project references as much as it practical.

Mike Mooney
I see what you mean, and that's worth bearing in mind for the future, but the source in question here is a website project, not a class library.
David
A: 

Pay attention to the "Output" window in visual studio. It will tell you what assemblies are loaded and when. You may see that an older version of your assembly somewhere in the folder is being loaded. For example if you have multiple assemblies and you are currently trying to break in one of the support assemblies, the CLR will handle the assembly resolving, which may load another assembly file than the one you have referenced in the visual studio project.

Tormod
Also worth bearing in mind, but I don't think it's the problem here since I'm trying to break into a website project, not a class library.
David
+1  A: 

I made a notice myself as building a program what synchronizes time from remote server at start when program is started to run/debug. Just in this second when my debugged program syncs time with my development machine, the source codes get out of sync and debugging is no more possible because my development machines time is slighly different from when it was builded.

So make sure nothing , not ur developed program or anything else moves your computers clock while you try to debug.

Also, if u had these problems and just clicked all pop-up windows in great hate, make sure you dont have any of your files on solutions properties ignore source code list. That list can be found on -> Solution->Properties->Debug Source Files->Do not look for these source files:

Tomi