简体   繁体   English

C#.NET VS2010 断点不起作用

[英]C#.NET VS2010 Break-Points Not Working

When I go to debug my code all my breakpoints are transparently filled (leaving only the outline) and a small triangle with an exclamation point in the middle is in the corner of the break-point.当我 go 调试我的代码时,我的所有断点都被透明填充(只留下轮廓),中间有一个感叹号的小三角形位于断点的角落。

The error when I hover over the break-point is 'The break-point will not currently be hit.当我 hover 超过断点时的错误是'断点当前不会被命中。 The source code is different from the original version.'源代码与原始版本不同。

I had not tried to debug my code in over an hour, and during that time I added a new class with multiple threading functions.我已经有一个多小时没有尝试调试我的代码了,在那段时间里,我添加了一个具有多线程功能的新 class。

Steps I have taken:我已采取的步骤:

  1. Clean and rebuild project清理并重建项目
  2. Set option 'On Run, when build or deployment errors occur:' to 'Do not launch'将选项“运行时,发生构建或部署错误时:”设置为“不启动”
  3. Re-save project.重新保存项目。
  4. Move project folder off of flash drive and onto HD将项目文件夹从 flash 驱动器移到 HD 上
  5. Close and reopen VS2010关闭并重新打开 VS2010

I had the same problem and it was because VS2010 was not generating debug symbols.我遇到了同样的问题,这是因为 VS2010 没有生成调试符号。 I had inadvertently changed a setting whiel trying to analyze a dump file.我在尝试分析转储文件时无意中更改了设置。 I was able to fix it this way:我能够以这种方式修复它:

  1. From the Tools menu, select Options工具菜单中,select选项
  2. In the Debugging Section select the Symbols dialogue调试部分 select 中的符号对话框
  3. At the bottom, under Automatically load symbols for select All modules, unless excluded在底部,在自动加载 select 的符号所有模块,除非排除在外
  4. click the Specify excluded modules link and make sure the list is empty.单击指定排除模块链接并确保列表为空。

I understand that your class is executed, but the breakpoints are not hit, and that when you build and run your solution, you find a newly created assembly in your build folder.我了解您的 class 已执行,但未命中断点,并且当您构建并运行解决方案时,您会在构建文件夹中找到一个新创建的程序集。

To find out where VS is taking your assembly from you could first of all set a breakpoint in some class you have not modified, so it will certainly be hit (eg at the end of your Main).要找出 VS 从您那里获取您的程序集,首先可以在您尚未修改的一些 class 中设置一个断点,因此它肯定会被命中(例如在您的 Main 末尾)。 When the breakpoint is hit look for your assembly in AppDomain.CurrentDomain.GetAssemblies(), and here look for the Location property which should give you the path your assembly has been loaded from.当断点被击中时,在 AppDomain.CurrentDomain.GetAssemblies() 中查找您的程序集,并在此处查找应该为您提供程序集加载路径的 Location 属性。

I got the same error and solved with the help of this link http://www.codeproject.com/Questions/248735/There-is-no-Source-code-available-for-the-current我遇到了同样的错误并在此链接http://www.codeproject.com/Questions/248735/There-is-no-Source-code-available-for-the-current的帮助下解决了

Go to Tools ---> Options --->Debugging ---> General ---> Uncheck "Require source file to exactly match the original version" ---> click ok. Go 到工具--->选项--->调试--->常规--->取消选中“要求源文件与原始版本完全匹配”--->点击确定。 This works for VS 2010这适用于 VS 2010

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM