在Visual Studio中调试时,有时我添加了一个断点,但它是空心的,VS说“断点目前不会被击中。”源代码与原始版本不同。”显然,这使我无法进行调试。

这条消息到底是什么意思?什么原始版本?如果我只是打开了解决方案,而没有对代码做任何更改,又怎么会有“原始版本”呢?


当前回答

我在一个分层架构项目的几个项目中遇到了同样的问题,问题是在配置中,所选项目的构建复选框没有被选中。所以这个问题在一个项目中得到了解决。

对于另一层,即使在配置中启用了构建,它也会带来同样的麻烦。我做了所有其他的选择,比如重新开始清理项目,但没有一个有用。最后,我取消了该特定项目的build复选框,并进行了清理和重建。他们再次标记了复选框,并照做了 相同的。然后问题就解决了。

希望这能有所帮助。

其他回答

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.

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

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

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

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

在我的例子中,其他建议都不起作用,但是重新克隆我的存储库使这个问题消失了。

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.

如果您正在使用激活器,而设置断点的程序集尚未加载,则可以获得此消息。

一旦激活器加载程序集(假设程序集和调试符号是最新的),断点将被解析。查看调试菜单中的模块窗口是一个好地方。在那里您应该寻找您的文件所属的程序集。首先检查程序集是否加载。那么,从哪里装载的呢?然后,是符号文件加载。同样,符号文件从哪里加载?最后检查两者的版本。