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

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


当前回答

确保在csproj中将<Optimize>false</Optimize>设置为false

其他回答

我只是重新装填,清理和重建我的作品。

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.

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

我之前一直在摆弄我的csproj文件。所以在项目属性(VS 2013) > Web选项卡>服务器部分>[下拉],我有“IIS快速”选择当我以前有“本地IIS”选择。一旦我将设置修正为之前的设置,断点就可以工作了。

至:

Tools > Options > Debugging > General > unchecked "要求源 文件与原始版本完全匹配”

在我的案例中,问题在于ASP。在项目属性>>Web下未启用NET调试