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

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


当前回答

在尝试调试时,请确保您没有处于发布模式。

其他回答

我也遇到过这种情况。导致我的问题的条件:

我正在本地运行一个完整的IIS7实例 我正在把我的软件分成不同的项目

我打开以前的版本导致了这个问题(VS提示问我是否想在IIS调试中指向这个实例,我回答'是'),然后打开当前版本(再次响应IIS提示'是'),然后尝试在以前的版本中调试。

为了解决这个问题,我只是关闭并重新打开了之前的预期版本,再次将其断言为调试源。

以我为例,我正在开发一个Windows CE应用程序,该应用程序在模拟器上进行测试。问题是可执行文件没有部署到模拟器中,因此.pdb(在开发环境中)与.exe(在模拟器中)不同步,因为新的.exe从未复制到模拟器中。我必须删除模拟器中的.exe,以强制进行新的部署。然后就成功了。

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

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

对于一个类似的问题,我做了如下处理:

取消选中Debug -> option -> General菜单中的“Enable Just My Code”选项

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.

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