在Visual Studio中调试时,有时我添加了一个断点,但它是空心的,VS说“断点目前不会被击中。”源代码与原始版本不同。”显然,这使我无法进行调试。
这条消息到底是什么意思?什么原始版本?如果我只是打开了解决方案,而没有对代码做任何更改,又怎么会有“原始版本”呢?
在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.
这也是一个重新保存网页的选项。配置以碰撞其修改时间。
在某些情况下,重新编译和重新构建并不能帮助克服这个问题。 另一个潜在的解决方案是从解决方案资源管理器中删除带断点的源文件,然后重新添加它(例如通过从文件夹中拖放)。
VS 2017的一些版本(结合。editorconfig)也有一个问题:从15.3开始,当文件的字符集与.editorconfig (utf8或utf8-bom)中的字符集不一致时,断点就不起作用了。
对我来说,解决方案隐藏在项目属性的高级构建设置中:
由于未知的原因,它被设置为none:将其设置为full会导致命中断点。
要进入此对话框,请打开项目属性,然后转到构建,然后选择高级…按钮在页面底部。
我只是重新装填,清理和重建我的作品。