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

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


当前回答

首先,我尝试从命令行;

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

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.

在我的例子中,我在VS 2012中附加了一个正在运行的进程。当附加时,你可以选择以各种模式(本机、脚本、silverlight、托管2.0、托管4.0等)进行调试。默认情况下,调试器自动选择模式。然而,自动并不总是做出正确的选择。如果进程包含多种类型的代码,请确保调试器使用的是正确的代码。