visual-studio 当前不会命中断点,为什么不?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1468726/
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
breakpoint will not currently be hit, why not?
提问by mrblah
Sometimes I get the message that the breakpoint will not be hit, and no symbols will be loaded.
有时我会收到断点不会被命中的消息,并且不会加载任何符号。
The red icon in vs.net changes color, and the debug mode just doesn't work.
vs.net中红色图标变色,调试模式不工作。
what is the reason for this?
这是什么原因?
回答by MacGyver
Do each bullet in the link below ONE AT A TIME, but repeat my steps below with each one you try.
一次执行以下链接中的每个项目符号,但对您尝试的每个项目重复以下步骤。
1.) Stop debugging (press red square icon) in Visual Studio
2.) Clean Solution
3.) Build Solution
4.) [INSERT BULLET INSTRUCTION HERE]
5.) Tools > Attach to Process (or start with debugging)
6.) Start the program that you're attaching to, and run it such that your code will get hit
1.) 在 Visual Studio 中停止调试(按红色方形图标)
2.) 清理解决方案
3.) 构建解决方案
4.) [在此处插入项目符号说明]
5.) 工具 > 附加到进程(或从调试开始)
6.)启动您要附加到的程序,然后运行它,这样您的代码就会被命中
6 explained:
6 解释:
If attaching to nunit.exe, then open NUnit and run a test so your breakpoint will be hit
如果附加到 nunit.exe,则打开 NUnit 并运行测试,以便您的断点被命中
If attaching to w3wp.exe (IIS site), then open your site in the browser and go to the page that will hit your breakpoint
如果附加到 w3wp.exe(IIS 站点),则在浏览器中打开您的站点并转到将命中断点的页面
回答by tal
- for manage code only - theres a good answer for this problem on the following site: http://geekswithblogs.net/dbutscher/archive/2007/06/26/113472.aspx
- for native + managed code - in the startup solution properties-> Debug tab make sure that "enable unmanaged code debugging" check box is checked
- 仅用于管理代码 - 在以下站点上有一个很好的解决此问题的答案:http: //geekswithblogs.net/dbutscher/archive/2007/06/26/113472.aspx
- 对于本机 + 托管代码 - 在启动解决方案属性中 -> 调试选项卡确保选中“启用非托管代码调试”复选框
回答by Yigit
回答by daveomcd
After trying several suggested fixes for this I did the following to get it working.
在为此尝试了几个建议的修复程序后,我执行了以下操作以使其正常工作。
- Right Clicked my Project in the Solution Explorer and selected "Properties".
- Went to the "Web" section and made sure "Start Action" was set to "Current Page".
- 在解决方案资源管理器中右键单击我的项目并选择“属性”。
- 转到“Web”部分并确保“开始操作”设置为“当前页面”。
Spent 3 1/2 hours on that... I'm going to go get a drink now.
花了 3 1/2 小时...我现在要去喝一杯。
回答by abshar
回答by Adriaan Stander
This can happen if the symbol fiels are different from the assembly (remote debugging), or when there is no "direct path", so the assembly hasent been load, but might be loaded using reflection and loading of the required assembly at run time.
如果符号字段与程序集不同(远程调试),或者没有“直接路径”,则程序集尚未加载,但可能会在运行时使用所需程序集的反射和加载进行加载,则可能会发生这种情况。
回答by Aaron Daniels
This can also happen if the debugger is not attached to the process for whatever reason. If it's the case, you can always go to Debug - Attach to Process... and choose the right process. Your breakpoints should return to normal once VS determines it can hit them.
如果调试器由于某种原因未连接到进程,也会发生这种情况。如果是这种情况,您可以随时转到调试 - 附加到进程...并选择正确的进程。一旦 VS 确定它可以击中它们,您的断点应该会恢复正常。
回答by Marc Bernier
What does it say when you hover the mouse over the disabled breakpoint? It will usually tell you the problem. My favorite is the old 'source code is out of date', especially when I'm debugging a DLL. Another favorite is when the file you're looking at isn't the one you're debugging (a copy in another folder?). If it's a case where you can breakpoint a caller routine, but not the callee, stepping into the callee will force VS to open the 'proper' source file and you'll be able to set breakpoints. Confusing, I usually swear at VS at this point, it seems to help.
当您将鼠标悬停在禁用的断点上时,它会说什么?它通常会告诉你问题所在。我最喜欢的是旧的“源代码已过时”,尤其是在我调试 DLL 时。另一个最喜欢的情况是您正在查看的文件不是您正在调试的文件(另一个文件夹中的副本?)。如果您可以断点调用者例程,但不能断点被调用者,则进入被调用者将强制 VS 打开“正确”的源文件,您将能够设置断点。令人困惑的是,我通常在这一点上对 VS 发誓,这似乎有帮助。
回答by eaglei22
I had the same problem. Which I know is normally if the build versions are different, and something isn't matching up. I cleaned my project, rebuilt it, and then deployed and that got everything back in-sync.
我有同样的问题。我所知道的通常是构建版本不同,并且某些内容不匹配。我清理了我的项目,重建了它,然后进行了部署,这让一切都恢复了同步。
回答by CarneyCode
I do not like to play with knives but the only thing that worked for me involved editing the .csproj file itself. So, unload the project file, edit it by cutting and pasting the three asp.net files so that they are together in the ItemGroup. However, sometimes it is necessary to go further as explained here: http://carnotaurus.tumblr.com/post/4130422114/visual-studio-debugging-issue-with-files-of-the-same- Also, I give a list of other proposed solutions that did not work for me. I hope it helps.
我不喜欢玩刀,但唯一对我有用的东西就是编辑 .csproj 文件本身。因此,卸载项目文件,通过剪切和粘贴三个 asp.net 文件来编辑它,使它们一起在 ItemGroup 中。但是,有时有必要按照此处的说明走得更远:http: //carnotaurus.tumblr.com/post/4130422114/visual-studio-debugging-issue-with-files-of-the-same- 另外,我给出其他对我不起作用的建议解决方案列表。我希望它有帮助。


