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

这也是一个重新保存网页的选项。配置以碰撞其修改时间。

其他回答

我的问题有点愚蠢。我有两份我的项目副本,我在visual studio中混合文件。

假设你有projectX和projectY。这些项目都包含myFile.cs。我打开projectX并编辑myFile.cs。但是这个myfile。cs属于project。(可以在visual studio中打开来自不同项目的文件)所以在这种情况下,警告说源代码将不同于原始。

在“解决方案配置”中选择“调试”,而不是“发布”

确保在csproj中将<Optimize>false</Optimize>设置为false

有一个几乎察觉不到的设定为我解决了这个问题。 如果有一个特定的源文件没有命中断点,则可以将其列在

解决方案资源管理器 右键单击解决方案 属性 公共属性 调试源文件 "不要找这些源文件"

出于某种我不知道的原因,VS 2013决定在那里放置一个源文件,随后,我无法在该文件中点击断点。这可能是“源代码与原始版本不同”的罪魁祸首。

在我的案例中,问题在于ASP。在项目属性>>Web下未启用NET调试