在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.
我发现当断点在不能被打断的行上时发生错误。我没有显示工具提示,是为了直接显示后面没有错误的行。
至:
Tools > Options > Debugging > General > unchecked "要求源 文件与原始版本完全匹配”
VS 2017的一些版本(结合。editorconfig)也有一个问题:从15.3开始,当文件的字符集与.editorconfig (utf8或utf8-bom)中的字符集不一致时,断点就不起作用了。
对我来说,没有一个项目能解决这个问题。我只是在函数中添加了一行新代码,类似于:
int a=0;
通过添加这个,我想我触发了visual studio在原始版本中添加这个功能