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

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

其他回答

我刚刚重启电脑,它为我工作得很好。

我在使用本地IIS而不是IIS express时遇到了这个问题。IIS中的文件源确实与Visual Studio中的文件源相匹配,但是,我不得不在IIS中回收应用程序池,以便让它使用新构建的dll。

Exit from vs ->删除“。vs”文件夹。->打开VS. ->运行项目。

上述解决方案对我很有效。希望这也能对你有所帮助。

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

对我来说,那是在做一个网站项目的时候。在清理了这些临时文件夹后,我得到了正确的编译器错误:

C:\Documents and Settings\ %username%\AppData\Local\Temp\临时 ASP。网络文件 C: \ windows \ Microsoft.NET \ Framework \ v4.0.30319 \临时ASP。网 文件

我最终解决了这个问题,当我发现一个类文件,我故意移动到一个子文件夹,以某种方式重新出现在根文件夹。当我在编辑另一个的时候,VS用了那个。