“The breakpoint will not currently be hit. The sou

2020-01-23 10:30发布

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

30条回答
等我变得足够好
2楼-- · 2020-01-23 11:01

What worked for me was to change the solution platform from x86 to Any CPU. After changing to Any, I set a stop address, ran the website, opened the page, clicked the button and it stopped. I closed the site, changed back to x86 and performed the same sequence successfully.

查看更多
甜甜的少女心
3楼-- · 2020-01-23 11:02

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!

查看更多
相关推荐>>
4楼-- · 2020-01-23 11:03

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.

查看更多
Luminary・发光体
5楼-- · 2020-01-23 11:03

It happened to me because I had other projects in the solution that weren't building. After I unloaded those problematic projects (right-click on the project in the solution explorer -> Unload Project), rebuilt the solution and ran again -- the breakpoint was hit!

查看更多
何必那么认真
6楼-- · 2020-01-23 11:05

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
查看更多
霸刀☆藐视天下
7楼-- · 2020-01-23 11:05

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

查看更多
登录 后发表回答