在Visual Studio中调试时,有时我添加了一个断点,但它是空心的,VS说“断点目前不会被击中。”源代码与原始版本不同。”显然,这使我无法进行调试。
这条消息到底是什么意思?什么原始版本?如果我只是打开了解决方案,而没有对代码做任何更改,又怎么会有“原始版本”呢?
在Visual Studio中调试时,有时我添加了一个断点,但它是空心的,VS说“断点目前不会被击中。”源代码与原始版本不同。”显然,这使我无法进行调试。
这条消息到底是什么意思?什么原始版本?如果我只是打开了解决方案,而没有对代码做任何更改,又怎么会有“原始版本”呢?
当前回答
I suffered from this recently, and in my case I traced the problem back to something I was doing when testing: changing the system time. I'm not suggesting this is the case for everyone, but thought I'd mention it since it hasn't been mentioned already. It appears if you start moving the clock around between debug builds then it can get very confused about what order various files have been created it - I can only assume it is using file modified dates to determine if the source code is valid or not, and which binaries it needs to recompile.
这也是一个重新保存网页的选项。配置以碰撞其修改时间。
其他回答
对我有用的是将解决方案平台从x86改为Any CPU。在更改为Any后,我设置了一个停止地址,运行网站,打开页面,点击按钮,它就停止了。我关闭了网站,改回x86并成功地执行了相同的顺序。
有一个几乎察觉不到的设定为我解决了这个问题。 如果有一个特定的源文件没有命中断点,则可以将其列在
解决方案资源管理器 右键单击解决方案 属性 公共属性 调试源文件 "不要找这些源文件"
出于某种我不知道的原因,VS 2013决定在那里放置一个源文件,随后,我无法在该文件中点击断点。这可能是“源代码与原始版本不同”的罪魁祸首。
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.
在“解决方案配置”中选择“调试”,而不是“发布”
我刚刚重启电脑,它为我工作得很好。