在Visual Studio中调试时,有时我添加了一个断点,但它是空心的,VS说“断点目前不会被击中。”源代码与原始版本不同。”显然,这使我无法进行调试。
这条消息到底是什么意思?什么原始版本?如果我只是打开了解决方案,而没有对代码做任何更改,又怎么会有“原始版本”呢?
在Visual Studio中调试时,有时我添加了一个断点,但它是空心的,VS说“断点目前不会被击中。”源代码与原始版本不同。”显然,这使我无法进行调试。
这条消息到底是什么意思?什么原始版本?如果我只是打开了解决方案,而没有对代码做任何更改,又怎么会有“原始版本”呢?
当前回答
我发现当断点在不能被打断的行上时发生错误。我没有显示工具提示,是为了直接显示后面没有错误的行。
其他回答
你做过这种事吗?
是否继续运行最后一个成功的构建?
如果您勾选了方框并按下“是”,即使您的项目没有编译,您也将成功运行最后一个构建。这意味着无论何时设置断点,都将得到该错误。
试着改变这个值:
工具 选项 项目和解决方案 构建并运行 在运行时,发生构建或部署错误时:不启动
对于一个类似的问题,我做了如下处理:
取消选中Debug -> option -> General菜单中的“Enable Just My Code”选项
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.
检查解决方案中是否有多个具有该名称的文件。
这是我从别人那里接手的一个项目。在Controller.cs中,断点列表充满了行号,有些是活动的,有些不是。我找到了这个问题,并尝试了一些选项,但是当我双击断点时,它们将我带到解决方案中的不同项目。因为文件被称为相同,所以它们看起来是相同的,但实际上不是。答案当然是忽略这个警告,因为如果你要加载另一个文件,它们就会变得活跃。
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.
这也是一个重新保存网页的选项。配置以碰撞其修改时间。