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

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

其他回答

你做过这种事吗?

是否继续运行最后一个成功的构建?

如果您勾选了方框并按下“是”,即使您的项目没有编译,您也将成功运行最后一个构建。这意味着无论何时设置断点,都将得到该错误。

试着改变这个值:

工具 选项 项目和解决方案 构建并运行 在运行时,发生构建或部署错误时:不启动

我的问题有点愚蠢。我有两份我的项目副本,我在visual studio中混合文件。

假设你有projectX和projectY。这些项目都包含myFile.cs。我打开projectX并编辑myFile.cs。但是这个myfile。cs属于project。(可以在visual studio中打开来自不同项目的文件)所以在这种情况下,警告说源代码将不同于原始。

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

对我来说;我的网站在默认网站(http://localhost/myapp/)下的IIS应用程序中运行,并且IIS应用程序的映射指向的磁盘路径与我正在处理的源代码不同。

解决;重新映射您的IIS应用程序到与您正在构建的源代码相同的路径。

(如果您在磁盘的不同位置运行同一个应用程序的多个版本,就会发生这种情况)

对我来说,没有一个项目能解决这个问题。我只是在函数中添加了一行新代码,类似于:

int a=0;

通过添加这个,我想我触发了visual studio在原始版本中添加这个功能