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

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

尽管所有的答案,我的问题实际上不同于这里提到的!

确保您的属性->构建选项卡->输出路径指向与您所选择的构建配置的解决方案中所有其他项目相同的位置!

如果你的启动项目将它的可执行文件从你试图调试的dll发送到不同的文件夹,你可能会遇到问题,尽管你的构建和visual studio工作完美。

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

关闭Visual Studio并重新打开解决方案可以修复这个问题,即它是IDE本身的一个bug(我正在运行VS2010)。

如果有多个Visual Studio实例正在运行,则只需关闭运行有问题的解决方案的实例。

有时您只需要将解决方案配置从“发布”更改为“调试”。