Visual Studio 断点警告 [英] Visual Studio Breakpoint Warning

查看:45
本文介绍了Visual Studio 断点警告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在调试我的代码时,我经常抛出断点来检查局部变量的值,以确保一切都在正确的轨道上.

When debugging my code, I often throw breakpoints in to check the values of local variables to make sure everything is on the right track.

最近,当我对代码进行更改并重新编译时,我所有的断点都变成了一个圆圈的轮廓(而不是一个完整的红色圆圈),并且它给了我一个错误;

Lately, when I make changes to my code and recompile, all my breakpoints turn into the outline of a circle (instead of a full red circle) and it gives me an error that reads;

当前不会命中断点.没有可执行代码与这条线有关.可能的原因包括: 有条件的编译或编译器优化.

The breakpoint will not currently be hit. No executable code is associated with this line. Possible causes include: conditional compilation or complier optimizations.

这个问题的奇怪之处在于我可以简单地删除和添加断点,一切都会完全正常.

What's strange about this issue is that I can simply remove and add the breakpoint and everything will work completely fine.

我没有使用任何类型的条件编译或编译器优化.有谁知道这是什么意思或如何解决这个问题?每次编译时都要替换 10-12 个断点,这很烦人.

I am not using any type of conditional compilation or complier optimizations. Does anyone know what this means or how to fix this? It gets quite annoying replacing 10-12 breakpoints each time I compile.

推荐答案

发生这种情况的原因有几个

This can happen for a few reasons

  • 调试器使用的代码与应用程序运行的代码不同
  • 调试器使用的 pdb 文件与应用程序运行的代码不同
  • 应用程序运行的代码已经过优化,调试信息已被删除.
  • 设置断点的代码尚未加载到进程中(假设上述内容不是罪魁祸首)
  • 如果您要附加调试器,请注意它附加到的 .net 框架(当代码全部为 .net 2.0 时,我在使用 .net 4 时遇到了问题)
  • 您拥有的程序集也在 GAC 中.如果说您安装了程序以便调试,但安装程序将 dll 放在 GAC 中,则可能会发生这种情况.
  • 删除引用并重新添加它(感谢 forsvarir).通常,当引用的项目不在解决方案中时会发生这种情况,VS 会从另一个项目的 bin 目录中复制 dll.当您尝试重新添加引用但找不到项目时,您就会知道这是问题:)
  • The code the debugger is using is different from the code that the application is running
  • The pdb file that the debugger is using is different from the code that the application is running
  • The code the application is running has been optimized and debug information has been stripped out.
  • The code in which you have breakpoints on hasn't been loaded into the process yet (assuming the things above are not the culprits)
  • If you are attaching the debugger, pay attention to what .net framework it's attaching to (i've had issues with it using .net 4 when code was all .net 2.0)
  • The assembly you have is also in the GAC. This might happen if say you installed your program so you could debug it, but the installer put the dll in the GAC.
  • Remove the reference and re-add it (thanks to forsvarir). Typically this occurs when the project that is referenced is not in the solution, and VS will copy the dll from the bin directory of another project. You will know this was the issue when you try to re-add the reference, and can't find the project :)

很难弄清楚这里发生了什么,但我建议使用融合日志查看器查看正在加载的内容以及从何处加载,然后您可以查看 dll 并查看它是否是旧代码,等

It's pretty tough to figure out what's going on here, but i would suggest using the fusion log viewer to see what is being loaded and where it's being loaded from and then you can look at the dll and see if it's old code, etc.

这篇关于Visual Studio 断点警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆