在Visual Studio中调试时,有时我添加了一个断点,但它是空心的,VS说“断点目前不会被击中。”源代码与原始版本不同。”显然,这使我无法进行调试。
这条消息到底是什么意思?什么原始版本?如果我只是打开了解决方案,而没有对代码做任何更改,又怎么会有“原始版本”呢?
在Visual Studio中调试时,有时我添加了一个断点,但它是空心的,VS说“断点目前不会被击中。”源代码与原始版本不同。”显然,这使我无法进行调试。
这条消息到底是什么意思?什么原始版本?如果我只是打开了解决方案,而没有对代码做任何更改,又怎么会有“原始版本”呢?
当前回答
从Visual Studio 2017 15.3.1到15.3.5,出现了解决此问题的新方法。如果您正在使用EditorConfig,则charset=utf8选项会导致这些症状。VS团队已经复制了这个,并表示他们正在努力。
因此,一个修复方法是注释掉.editorconfig文件中的charset=utf8行。
编辑:这应该在VS 15.5被修复。
其他回答
在尝试调试时,请确保您没有处于发布模式。
VS 2017的一些版本(结合。editorconfig)也有一个问题:从15.3开始,当文件的字符集与.editorconfig (utf8或utf8-bom)中的字符集不一致时,断点就不起作用了。
尽管所有的答案,我的问题实际上不同于这里提到的!
确保您的属性->构建选项卡->输出路径指向与您所选择的构建配置的解决方案中所有其他项目相同的位置!
如果你的启动项目将它的可执行文件从你试图调试的dll发送到不同的文件夹,你可能会遇到问题,尽管你的构建和visual studio工作完美。
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等)进行调试。默认情况下,调试器自动选择模式。然而,自动并不总是做出正确的选择。如果进程包含多种类型的代码,请确保调试器使用的是正确的代码。