.net “目前不会打断点,源码和原版不一样。” 这是什么意思?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2468852/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-03 14:06:17  来源:igfitidea点击:

"The breakpoint will not currently be hit. The source code is different from the original version." What does this mean?

.netvisual-studiodebugging

提问by David

When debugging in Visual Studio, sometimes I add a breakpoint but it's hollow and VS says "The breakpoint will not currently be hit. The source code is different from the original version." Obviously this prevents me from being able to debug.

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

What on earth does the message mean? What original version? If I've just opened up the solution and not made any changes whatsoever to the code, how can there be an 'original version'?

这条消息到底是什么意思?什么原版?如果我刚刚打开解决方案并且没有对代码进行任何更改,怎么会有“原始版本”?

回答by André Alves

As it says, the "source code is different from the original version".

正如它所说,“源代码与原始版本不同”。

Right click on the project folder inside the solution explorer and choose to Clean. Build a new version of the project and the breakpoint will work again!

右键单击解决方案资源管理器中的项目文件夹,然后选择Clean. 构建一个新版本的项目,断点将再次起作用!

回答by Oliver

If you have unchecked the DLL project in the Debug build configuration, your new code will never be built!

如果您在 Debug 构建配置中取消选中 DLL 项目,您的新代码将永远不会构建!

Go to Build --> Configuration Manager ...(in VS2010) and check if the project with the code you're trying to debug is checked for the current build configuration.

转到Build --> Configuration Manager ...(在 VS2010 中)并检查是否针对当前构建配置检查了包含您尝试调试的代码的项目。

回答by AnthonyVO

For me it was while working on a WebSite project. After cleaning up these temp folders I got the proper compiler errors back:

对我来说,那是在做网站项目时。清理这些临时文件夹后,我得到了正确的编译器错误:

  • C:\Documents and Settings\%username%\AppData\Local\Temp\Temporary ASP.NET Files
  • C:\windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files
  • C:\Documents and Settings\%username%\AppData\Local\Temp\Temporary ASP.NET Files
  • C:\windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files

I finally resolved the problem when I discovered that a class file I had intentionally moved into a subfolder, somehow reappeared in the root folder. VS was using that one while I was editing the other.

当我发现我故意移动到子文件夹中的类文件以某种方式重新出现在根文件夹中时,我终于解决了问题。当我编辑另一个时,VS 正在使用那个。

回答by Codesleuth

Did you ever do this?

你有没有这样做过?

Would you like to continue and run the last successful build?

您想继续并运行上次成功的构建吗?

If you ticked the box and pressed "Yes" you will get the last successful build running even though your project does not compile. This means that whenever you set a breakpoint, you will get that error.

如果您勾选该框并按“是”,即使您的项目没有编译,您也会运行最后一次成功的构建。这意味着无论何时设置断点,都会收到该错误。

Try changing this value:

尝试更改此值:

  • Tools
    • Options
      • Projects and Solutions
        • Build and Run
          • On Run, when build or deployment errors occur: Do not Launch
  • 工具
    • 选项
      • 项目和解决方案
        • 构建和运行
          • 在运行时,当发生构建或部署错误时:不要启动

回答by Rachmad

Go to

  • Tools
    • Options
      • Debugging
        • General
  • 工具
    • 选项
      • 调试
        • 一般的

Uncheck Require source files to exactly match the original version

取消选中需要源文件与原始版本完全匹配

回答by AdiKonstantin

Select Debugin Solution Configurations, instead of Release

解决方案配置中选择调试,而不是发布

screenshot of menu

菜单截图

回答by Tormod

Pay attention to the "Output" window in VS. It will tell you what assemblies are loaded and when. You may see that an older version of your assembly somewhere in the folder is being loaded.

注意VS中的“输出”窗口。它会告诉您加载了哪些程序集以及何时加载。您可能会看到正在加载文件夹中某处的旧版本程序集。

For example if you have multiple assemblies and you are currently trying to break in one of the support assemblies, the CLR will handle the assembly resolving, which may load another assembly file than the one you have referenced in the project.

例如,如果您有多个程序集,并且您当前正尝试中断其中一个支持程序集,则 CLR 将处理程序集解析,这可能会加载另一个程序集文件,而不是您在项目中引用的程序集文件。

回答by Luke Whyte

Closing Visual Studio and reopening the solution can fix the problem, i.e. it's a bug within the IDE itself (I'm running VS2010).

关闭 Visual Studio 并重新打开解决方案可以解决问题,即这是 IDE 本身的错误(我正在运行 VS2010)。

If you have more than one instances of Visual Studio running, you only need to close the instance running the solution with the problem.

如果有多个 Visual Studio 实例正在运行,则只需关闭运行该解决方案的实例即可。

回答by John Hatton

A new way to get this problem has appeared as of Visual Studio 2017 15.3.1 through 15.3.5. If you are using EditorConfig, the charset=utf8option causes these symptoms. The VS team has reproduced this and says they are working on it.

从 Visual Studio 2017 15.3.1 到 15.3.5,出现了解决此问题的新方法。如果您使用的是EditorConfig,则该charset=utf8选项会导致这些症状。VS 团队已经复制了这一点,并表示他们正在努力解决这个问题

So one fix is to comment out your charset=utf8line in the .editorconfig file.

因此,一种解决方法是charset=utf8在 .editorconfig 文件中注释掉您的行。

Edit: This should be fixed as of VS 15.5.

编辑:这应该从 VS 15.5 开始修复。

回答by Mike Mooney

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.

如果您使用对二进制文件的文件引用(而不是对项目中代码的项目引用),并且您引用的编译后的二进制文件与您机器上的相应源代码不同步,这种情况也会经常发生。这可能是因为您从源代码管理下载了一个新版本的二进制文件,但没有附带新的源代码,或者您的机器上有几个版本的二进制文件并且正在引用旧副本等。如果这确实是问题是,尽可能多地使用项目引用是一个很好的理由。