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

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


当前回答

注意vs中的“Output”窗口,它会告诉你加载了哪些程序集以及何时加载。您可能会看到正在加载文件夹中某个位置的程序集的旧版本。

例如,如果您有多个程序集,并且当前正在尝试插入其中一个支持程序集,CLR将处理程序集解析,这可能会加载您在项目中引用的程序集文件以外的另一个程序集文件。

其他回答

我刚刚重启电脑,它为我工作得很好。

首先,我尝试从命令行;

从命令行删除临时文件确实有效。

C:\Windows\ Microsoft.NET \ Framework64 \ v4.0.30319 \临时ASP。>rd /s root . NET文件

当我在工具->选项->调试->通用中禁用“启用只是我的代码”选项时

这个问题为我解决了。这是一个WCF应用程序,试图调试一个ashx页面。 http://blogs.msdn.com/b/zainnab/archive/2010/10/25/understanding-just-my-code.aspx

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.

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

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

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

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