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'?
For me the solution was hidden in the
Advanced Build Settings
of the project properties:For an unknown reason it was set to
none
: setting it tofull
caused the breakpoints to be hit.To get to this dialog, open the project properties, then go to
Build
, then select theAdvanced...
button at the bottom of the page.go to:
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.
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.
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..
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.