628

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 from 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'?

9
  • 49
    recompile/build the project before adding the break-point Commented Mar 18, 2010 at 10:04
  • are you opening a project written in another version of visual studio ? Commented Mar 18, 2010 at 10:08
  • 2
    It's a website project. There should be no need to explicitly build it. It should compile on use. I suspect VS can't build the website, but it's not telling me that! Mahesh - no, all the same version of VS. Commented Mar 18, 2010 at 11:25
  • 8
    Deleting bin and obj directories than rebuilding worked for me. Commented Nov 28, 2014 at 10:18
  • 1
    In my case I had copied my project to a different folder, but the VS editor was still having me edit the source files in the old location so my changes weren't being built. Just had to copy the sources again and re-open the files from the new location so they actually got built. Commented Dec 12, 2019 at 16:18

72 Answers 72

329

As it says, the "source code is different from the original version".

Right click on the project folder inside the solution explorer and choose to Clean. Build a new version of the project and the breakpoint will work again!

Sign up to request clarification or add additional context in comments.

15 Comments

Using clean does not always work. I had to manually delete everything in my bin folder to get it to work again.
I mistakenly had a reference to a DLL in my bin folder. Correcting reference path fixed.
For me, even deleting the bin and obj folders didn't work. I had to restart Visual Studio as well.
I've closed VS, deleted all bin and obj folders, rebuild everything, double checked build configurations, build is succeeding. No dice. Simple things shouldn't be this complicated. >:|
It's still not working after deleting files from bin and obj folder.
|
146

If you have unchecked the DLL project in the Debug build configuration, your new code will never be built!

Go to Build --> Configuration Manager ... (in VS2010) and check if the project with the code you're trying to debug is checked for the current build configuration.

6 Comments

Thanks for the suggestion Oliver. That's definitely not been happening here, I would notice quite quickly if one of my projects wasn't building.
I had exactly the same issue, only did not had anything unchecked. it was just build for x86 in that dialog, while my local machine is x64! So I selected the Any CPU option and it works again.
Removing projects from the debug configuration without a valid reason should be a cardinal sin, as that config may well be used by the CI build machine (I know it is here), so ultimately could pass that when it should fail. I know it could be one of many build steps but still... @Oliver I hope the team member bought you some biscuits ! :)
I had this problem when I switched to build for x86 instead of AnyCPU. It removed projects from being built for some unknown reason.
The project is listed for Build in configuration manager so this hasn't helped me I'm afraid :(
|
56

Go to

  • Tools
    • Options
      • Debugging
        • General

Uncheck Require source files to exactly match the original version

6 Comments

@Rachmad This solution works. But it seems not the complete solution, because it means our source files is not exactly matches the original version
Even with this unchecked, execution doesn't hit the breakpoint and the error persists
This is NOT a solution to this problem but a workaround. Obviously I don't want to work with outdated files in the debugger.
@ObiWan Not obvious. I like to make minor edits and continue debugging even knowing the source and build are different.
This actually solved my problem. It didn't cover it up, it SOLVED it. My deploy process REQUIRES the DLL to be mutated in a way that the debugger doesn't recognize it but it DOES work if this setting is disabled. Don't assume this isn't the solution for anyone. This is 100% the specific and only solution to my issue. I wish I could upvote this answer twice for ~*answering the question as asked*~, something SO users seem to struggle with.
|
46

For me it was while working on a WebSite project. After cleaning up these temp folders I got the proper compiler errors back:

  • C:\Documents and Settings\%username%\AppData\Local\Temp\Temporary ASP.NET Files
  • C:\windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files

I finally resolved the problem when I discovered that a class file I had intentionally moved into a subfolder, somehow reappeared in the root folder. VS was using that one while I was editing the other.

4 Comments

Emptying out the temporary files in the windows directory worked for me, cheers!
I just wanted to add a similar answer - make sure, that no old copy of your project's dll is lying around in any of the temporary folders ASP.NET uses, like C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files - as mentioned - but also C:\Windows\Microsoft.NET\Framework_64_\v4.0.30319\Temporary ASP.NET Files. I use Everything to quickly search for those copies.
Just a quick hint: typing %localappdata% in search box takes you directly to C:\Documents and Settings\%username%\AppData\Local
Can confirm this worked for me in Visual Studio 2013 on a webservice project.
43

Did you ever do this?

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

4 Comments

I don't think I had done that. Thanks for the link though. It gave me an insight into what that prompt means!
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.
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.
Maybe if they had to show their superior when he suddenly came by. They could hit f5 and be like "you see, it works!"
33

Select Debug in Solution Configurations, instead of Release

screenshot of menu

2 Comments

This was my issue. I had compiled in debug mode, changed the code, then later ran it in release mode. No wonder the debugger thought the code was different - the debug symbols were different. When I deleted the bin folder as others suggested, I got an error "no symbols have been loaded for this document." It was only then that I made the connection, and made my way to this answer. It needs more votes!
It is possible for the project to be disabled for build even in the Debug build configuration. An examination of the build configuration is required, flip-flopping between Debug/Release configuration is pointless.
28

Pay attention to the "Output" window in VS. 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 project.

1 Comment

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

Closing Visual Studio and reopening the solution can fix the problem, i.e. it's a bug within the IDE itself (I'm running VS2010).

If you have more than one instances of Visual Studio running, you only need to close the instance running the solution with the problem.

6 Comments

Closing Visual Studio worked for me too. Also, with Clean / Rebuild actions.
This fixed the solution in VS 2015
Fixed isue in VS 2017
Fixed the problem in VS 2012
Fixed in VS 2019! Restart is the master solution for all computer difficulties :D!
|
27

A new way to get this problem has appeared as of Visual Studio 2017 15.3.1 through 15.3.5. If you are using EditorConfig, the charset=utf8 option causes these symptoms. The VS team has reproduced this and says they are working on it.

So one fix is to comment out your charset=utf8 line in the .editorconfig file.

Edit: This should be fixed as of VS 15.5.

4 Comments

Status is now "Fixed - pending release" as of two days ago (October 9, 2017). Which is good news, since UTF-8 is the only sane default for text encoding these days. :-)
I also notice that the ultimate cause of this issue was apparently this other bugfix, where charset=utf8 was being interpreted as "UTF-8 with BOM". Changing that interpretation to "without BOM" broke some UTF-8 files that had the BOM in them. So if you run into this issue and the Visual Studio fix hasn't been released yet, try removing the BOM from the beginning of your text files and that may fix the issue. (This comment is begging for a Zero Wing reference... :-) )
This was the problem for me as well. Currently, this is not fixed or at least released yet or bug was re-introduced (version 15.4.2)
This bug ist still (or again) existing in 2023. Short - charset in editorconfig and encoding of .cs file needs to be equal.
23

For me, none of the items solved the issue. I just added a new line of code inside that function, something like:

int a=0;

by adding that, I guess I triggered visual studio to add this function to the original version

3 Comments

That actually did it for me (when none of the above, including cleaning and manually deleting bin and obj, did) 👍
Why did this work..? Restarting visual studio, changing build architecture/mode, cleaning the solution and manually deleting the bin/obj directories did nothing. Where is this magic cache being stored?!
Ditto, I was in the same boat (nothing worked, nothing at all) and I refuse to uncheck "Require source files to exactly match the original version", and it was just a few files in a particular dll, not all, and then making some change to a file did the trick!
13

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.

2 Comments

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.
This is a common problem when picking up legacy code that leaves me scratching my head wondering which genius decided to reference a dll from a project in the solution that is only ever used by another project in the solution. sigh
10

I just reloaded, clean and rebuilt works for me.

Comments

9

There is an almost imperceptible setting that fixed this issue for me. If there is a particular source file in which the breakpoint isn't hitting, it could be listed in

  • Solution Explorer
    • right-click Solution
      • Properties
        • Common Properties
          • Debug Source Files
            • "Do not look for these source files".

For some reason unknown to me, VS 2013 decided to place a source file there, and subsequently, I couldn't hit breakpoint in that file anymore. This may be the culprit for "source code is different from the original version".

2 Comments

I faced the exact same problem. Your answer did help me! Thank you! +1
My file was indeed in there for some dark reason, I removed it but the breakpoint still is not working
8

The problem is that your debug info is not in sync with your assembly. The solution is simple:

  1. Go to your bin folder
  2. Remove the .pdb files
  3. Rebuild

Should do the trick!

(the weird thing is, a rebuild without throwing away the .pdb files doesn't always work. I can see the modified date being updated, but still somewhere in the chain (VS2013 debugger, IIS, assembly cache) this change is not detected)

2 Comments

Build->Clean Solution should also accomplish removing the files that need to be removed.
After huge amount loss of time lost because of this issue, this solution made the trick. Thx FrankyHollywood
7

This can happen when the system time changes while debugging or between debug sessions, be it programmatically, manually or by an external program.

1 Comment

I can't +1 this enough. I recently reinstalled Windows and didn't notice my system clock was off. Sure enough, this change screwed everything up, and rebuilding the entire solution/project magically fixed it.
7

Exit from VS. -> Delete the .vs folder. -> Open VS. -> Run the Project.

Above solution worked for me. Hope this will help you as well.

1 Comment

Had to do this, unfortunately some changes were lost...
6

If you have more than one projects in your solution, then make sure that the correct project is set as the StartUp Project. To set a particular project as the Startup Project of your solution, Right-click the project, choose Set As StartUp Project.

After I set my StartUp Project correctly, desired break-point was reached by the thread.

1 Comment

Worth also noting that if your breakpoint is in a project that is NOT your startup project, and it CANNOT be made your startup project (because e.g. you need to have a different project be the startup one) you can (after starting the main one) right click and choose Debug >> Start New Instance of the project that has the breakpoint in that you want to hit
6

I'm with this error in VS2019 and I think that it starts to occurs when Windows has clock changed.

1 Comment

Oh thank you! I forgot that I changed the clock time to test something then this problem occured. Now the debug tool works fine. (VB 2008)
5

You can get this message when you are using an activator and the assembly you set the breakpoint into has not been loaded yet.

The breakpoint will resolve once the activator loads the assembly (assuming the assembly and debug symbols are up to date). A good place to look at is the modules window in the debugging menu. There you should look for the assembly which your file belongs too. First check that the assembly is loaded. Then, from where is it loaded? Then, is the symbols file loaded. Again, where is the symbols file loaded from? Finally check the versions of both.

Comments

5

I encountered this as well. The conditions that caused my issue:

  • I'm running a full IIS7 instance locally
  • I'm versioning my software into separate projects

I had caused this by opening a previous version (VS prompted to ask if I wanted to point to this instance in IIS debugging, I answered 'Yes'), then opening the current version (again responding to the IIS prompt with a 'Yes'), then attempting to debug in the previous version.

To solve, I merely closed and re-opened the previous and intended version, once again asserting it as the debugging source.

Comments

5

I experienced this in a 32bit build on vs2017.

Exactly none of the solutions worked for me. I restarted, I cleared IDE files, clean built solution, pulled from git repo and rebuilt the solution to no avail.

I was pulling in a 64bit dependency from nuget and as soon as I used the assembly, the sources were not being built into the final executable anymore and instead the IDE cached sources were being built.

I removed the nuget configuration, removed the referenced assembly, downloaded the source, built log4net manually, signed it, added it to a folder in my project, added reference to it, and I was able to debug again.

This was a pain, I hope it gets up in the answers list for all to see.

Edit: There was no error during build despite having the option "prompt on build error" being turned on in the IDE settings.

Comments

5

For me the solution was hidden in the Advanced Build Settings of the project properties: enter image description here

For an unknown reason it was set to none: setting it to full caused the breakpoints to be hit.

To get to this dialog, open the project properties, then go to Build, then select the Advanced... button at the bottom of the page.

Comments

5

This happens also when debugging a C++ project which loads a module that has been implemented with some CLR language (Managed C++, C# etc). In this situation the error message is misleading indeed.

The solution is to put Common language runtime (CLR) support configuration property to the startup project and recompile that.

Comments

4

It happenned to be on Visual Studio 2017 after I added existing files to the project. This worked for me:

  1. close the solution,
  2. go to SolutionFolder\.vs\SolutionName\v15\sqlite3 and remove storage.ide
  3. open the solution again

1 Comment

Thank you for this solution! None before worked, and this saved my day :)
4

I had the same issue in several projects in a layered architecture project and the problem was in configurations the build check box for the selected project hasn't been checked. so the issue was fixed for one project.

For one other layer it was giving this same trouble even the build is enable in the configurations. I did all the other options like restarting cleaning the project but non of them helped. Finally I unchecked the build checkbox for that particular project and cleaned and rebuild. the again marked the checkbox and did the same. then the issue was fixed.

Hope this helps..

Comments

4

I've tried the proposed solutions but it didn't work.

In case you have multiple project, make the one you want to debug as the startup project.

enter image description here

Comments

3

Try disabling and re-setting the breakpoint while running in debug mode instead of doing it before launching debug mode.

Comments

3

First I tried from command line;

deleting temp files from command line did work.

C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files>rd /s root

When I disable "Enable Just My Code" option in Tools -> Options -> Debugging -> General

The problem resolved for me. It is a WCF application, was trying to debug an ashx page. http://blogs.msdn.com/b/zainnab/archive/2010/10/25/understanding-just-my-code.aspx

Comments

2

In my case, I was attaching to a running process in VS 2012. When attaching, you're given the option to debug in various modes (native, script, silverlight, managed 2.0, managed 4.0, etc). By default, the debugger selects the mode automatically. However Automatic does not always make the correct choice. If your process contains multiple types of code, be sure the debugger is using the correct one.

1 Comment

In my case I was attaching to w3wp.exe to debug .NET code but for some reason it was attaching the Script debugger which wasn't able to see my C# breakpoints. Changing it to the .NET debugger allowed my C# breakpoints to work.
2

In my case, I was developing a Windows CE app, that tested against an emulator. The problem was that the executable wasn't deployed to the emulator, so the .pdb (in the development environment) was out of sync with the .exe (in the emulator), because the new .exe was never copied to the emulator. I had to delete the .exe in the emulator to force a new deployment. Then it worked.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.