在Visual Studio中调试时,有时我添加了一个断点,但它是空心的,VS说“断点目前不会被击中。”源代码与原始版本不同。”显然,这使我无法进行调试。
这条消息到底是什么意思?什么原始版本?如果我只是打开了解决方案,而没有对代码做任何更改,又怎么会有“原始版本”呢?
在Visual Studio中调试时,有时我添加了一个断点,但它是空心的,VS说“断点目前不会被击中。”源代码与原始版本不同。”显然,这使我无法进行调试。
这条消息到底是什么意思?什么原始版本?如果我只是打开了解决方案,而没有对代码做任何更改,又怎么会有“原始版本”呢?
当前回答
在我的例子中,其他建议都不起作用,但是重新克隆我的存储库使这个问题消失了。
其他回答
当调试期间或调试会话之间的系统时间发生变化时,可能会发生这种情况,无论是通过编程方式、手动方式还是通过外部程序。
因为构建版本更改了(很可能您修改了源代码),所以重新编译解决方案并再次运行应用程序,之后它将到达调试断点。
这发生在我身上是因为我在解决方案中有其他项目没有构建。 在我卸载那些有问题的项目后(在解决方案资源管理器中右键单击项目->卸载项目),重新构建解决方案并再次运行—断点被击中!
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等)进行调试。默认情况下,调试器自动选择模式。然而,自动并不总是做出正确的选择。如果进程包含多种类型的代码,请确保调试器使用的是正确的代码。