“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:05

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.

查看更多
▲ chillily
3楼-- · 2020-01-23 11:06

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

查看更多
贪生不怕死
4楼-- · 2020-01-23 11:06

Make sure you are not in Release Mode when you try to debug.

查看更多
女痞
5楼-- · 2020-01-23 11:07

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.

查看更多
\"骚年 ilove
6楼-- · 2020-01-23 11:07

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

查看更多
smile是对你的礼貌
7楼-- · 2020-01-23 11:09

Select Debug in Solution Configurations, instead of Release

screenshot of menu

查看更多
登录 后发表回答