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

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


当前回答

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

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

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

其他回答

当调试期间或调试会话之间的系统时间发生变化时,可能会发生这种情况,无论是通过编程方式、手动方式还是通过外部程序。

在我的例子中,我忘记在我声明模板函数的头文件中包含“stdafx.h”。

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

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.

如果您在调试构建配置中未选中DLL项目,那么您的新代码将永远无法构建!

转到构建—>配置管理器…(在VS2010中),并检查您正在尝试调试的代码的项目是否为当前构建配置进行了检查。