.net “步入”突然在 Visual Studio 中不起作用
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10801385/
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
'Step Into' is suddenly not working in Visual Studio
提问by Nick LaMarca
All of a sudden, I have run into an issue where I cannot step into any code through debugging in Visual Studio. The step over works fine, but it refuses to step into (F11) any of my code. This was working before, now all of a sudden it does not.
突然间,我遇到了一个问题,即我无法通过 Visual Studio 中的调试进入任何代码。跳过工作正常,但它拒绝进入 ( F11) 我的任何代码。这在以前是有效的,现在突然之间没有了。
I've tried some things below, but I still had no success:
我在下面尝试了一些东西,但我仍然没有成功:
Delete all bin files in every project in my solution, clean solution, re-build solution.
Build projects in solution indivdualy
Restart machine
删除我的解决方案中每个项目中的所有 bin 文件,清理解决方案,重新构建解决方案。
在解决方案中单独构建项目
重启机器
It an ASP.NETC#application consuming a WCFsevice locally. It is in debug mode. I have a breakpoint set on the page consuming the service. The breakpoint hits, but it will not step into the service code.
它是一个在本地使用WCF服务的ASP.NET C#应用程序。它处于调试模式。我在使用服务的页面上设置了一个断点。断点命中,但不会进入服务代码。
The ASP.NET site and the service code is all in the same solution. This all of a sudden does not work, it did work before.
ASP.NET 站点和服务代码都在同一个解决方案中。这突然不起作用,它以前确实起作用。
How can I fix this problem?
我该如何解决这个问题?
Adding a breakpoint to the service project I get a warning:
向服务项目添加断点我收到警告:
Breakpoint will not currently be hit. No symbols have been loaded for this document.
当前不会命中断点。尚未为此文档加载任何符号。
I deleted all the bin folders for all the projects and re-built them one by one. They all succeeded, but still I am getting the symbols won't loadon any breakpoint I put into any project in the solution other than the ASP.NET project where the breakpoint works. I was able to debug step into all the projects before, this is an all of a sudden thing.
我删除了所有项目的所有bin文件夹,并一一重新构建它们。他们都成功了,但我仍然得到符号不会加载到我放入解决方案中任何项目的任何断点上,而不是断点工作的 ASP.NET 项目。我之前能够调试所有项目,这是突然的事情。
Information from the output window..
来自输出窗口的信息..
'WebDev.WebServer40.EXE' (Managed (v4.0.30319)): Loaded 'C:\windows\Microsoft.Net\assembly\GAC_MSIL\SMDiagnostics\v4.0_4.0.0.0__b77a5c561934e089\SMDiagnostics.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'WebDev.WebServer40.EXE' (Managed (v4.0.30319)): Loaded 'C:\windows\Microsoft.Net\assembly\GAC_MSIL\System.Runtime.DurableInstancing\v4.0_4.0.0.0__31bf3856ad364e35\System.Runtime.DurableInstancing.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'WebDev.WebServer40.EXE' (Managed (v4.0.30319)): Loaded 'C:\windows\Microsoft.Net\assembly\GAC_MSIL\System.Xaml.Hosting\v4.0_4.0.0.0__31bf3856ad364e35\System.Xaml.Hosting.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'WebDev.WebServer40.EXE' (Managed (v4.0.30319)): Loaded 'C:\windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\rootd49cf50eee2cf\App_Web_jmow15fw.dll', Symbols loaded.
'WebDev.WebServer40.EXE' (Managed (v4.0.30319)): Loaded 'C:\windows\Microsoft.Net\assembly\GAC_MSIL\System.Runtime.Serialization\v4.0_4.0.0.0__b77a5c561934e089\System.Runtime.Serialization.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'WebDev.WebServer40.EXE' (Managed (v4.0.30319)): Loaded 'C:\windows\Microsoft.Net\assembly\GAC_MSIL\System.WorkflowServices\v4.0_4.0.0.0__31bf3856ad364e35\System.WorkflowServices.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'WebDev.WebServer40.EXE' (Managed (v4.0.30319)): Loaded 'C:\windows\Microsoft.Net\assembly\GAC_MSIL\System.ServiceModel.Web\v4.0_4.0.0.0__31bf3856ad364e35\System.ServiceModel.Web.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'WebDev.WebServer40.EXE' (Managed (v4.0.30319)): Loaded 'C:\windows\Microsoft.Net\assembly\GAC_MSIL\System.ServiceModel.Discovery\v4.0_4.0.0.0__31bf3856ad364e35\System.ServiceModel.Discovery.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'WebDev.WebServer40.EXE' (Managed (v4.0.30319)): Loaded 'C:\windows\Microsoft.Net\assembly\GAC_MSIL\System.ServiceModel.Activities\v4.0_4.0.0.0__31bf3856ad364e35\System.ServiceModel.Activities.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'WebDev.WebServer40.EXE' (Managed (v4.0.30319)): Loaded 'C:\windows\Microsoft.Net\assembly\GAC_MSIL\System.ServiceModel.Routing\v4.0_4.0.0.0__31bf3856ad364e35\System.ServiceModel.Routing.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'WebDev.WebServer40.EXE' (Managed (v4.0.30319)): Loaded 'C:\windows\Microsoft.Net\assembly\GAC_MSIL\System.ServiceModel.Channels\v4.0_4.0.0.0__31bf3856ad364e35\System.ServiceModel.Channels.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'WebDev.WebServer40.EXE' (Managed (v4.0.30319)): Loaded 'C:\windows\Microsoft.Net\assembly\GAC_MSIL\System.IdentityModel\v4.0_4.0.0.0__b77a5c561934e089\System.IdentityModel.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
回答by AMissico
With Visual Studio closed:
关闭 Visual Studio:
- Delete the solution's suo file (contains debug information, user settings such as break points, bookmarks, and other user settings.)
- Delete the Visual Studio cache files (see below)
- Delete all temporary files (a shift from VS9 to VS10 is that VS10 uses the temp folder)
- Manually delete all obj and bin folders using Windows Explorer.
- 删除解决方案的 suo 文件(包含调试信息、断点等用户设置、书签和其他用户设置。)
- 删除 Visual Studio 缓存文件(见下文)
- 删除所有临时文件(从VS9到VS10的一个转变是VS10使用了temp文件夹)
- 使用 Windows 资源管理器手动删除所有 obj 和 bin 文件夹。
Open Visual Studio and rebuild all. This always works. See C# VS2010 Entering break mode failed.
打开 Visual Studio 并全部重建。这总是有效的。请参阅C# VS2010 进入中断模式失败。
For reference:
以供参考:
Private Sub ClearVS9
ClearFolder(oShell.ExpandEnvironmentStrings("%APPDATA%") & "\Microsoft\VisualStudio.0\ProjectAssemblies")
ClearFolder(oShell.ExpandEnvironmentStrings("%APPDATA%") & "\Microsoft\VisualStudio.0\Recent")
ClearFolder(oShell.ExpandEnvironmentStrings("%USERPROFILE%") & "\Local Settings\Application Data\ApplicationHistory")
ClearFolder(oShell.ExpandEnvironmentStrings("%USERPROFILE%") & "\Local Settings\Application Data\Microsoft\VisualStudio.0\ProjectAssemblies")
ClearFolder(oShell.ExpandEnvironmentStrings("%WINDIR%") & "\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files")
End Sub
Private Sub ClearVS10
ClearFolder(oShell.ExpandEnvironmentStrings("%APPDATA%") & "\Local\Microsoft\WebsiteCache")
ClearFolder(oShell.ExpandEnvironmentStrings("%APPDATA%") & "\Local\Microsoft\VisualStudio.0\ProjectAssemblies")
End Sub
See the link The evil suo file - fighting and winning with Visual Studiomentioned by JMarsch.
请参阅JMarsch 提到的链接邪恶的 suo 文件 - 与 Visual Studio 战斗并获胜。
回答by Josh Noe
In my case, I was stepping into a method which yielded return of an IEnumerable. In this situation, F11 may skip over the method until the IEnumerableis iterated, since its execution is deferred until then.
就我而言,我正在使用一种产生IEnumerable. 在这种情况下,F11 可能会跳过该方法直到IEnumerable被迭代,因为它的执行被推迟到那时。
回答by user2721607

My issue was that when I set a breakpoint the code would properly stop at that point but when I pressed F10or F11the code would simply finish running instead of going to the next line. I also noticed that while the code was stopped at the breakpoint I could not use my cursor to hover over my variables to see their values. Here is how I corrected the problem:

我的问题是,当我设置断点时,代码会在该点正确停止,但是当我按下F10或F11代码会简单地完成运行而不是转到下一行。我还注意到,当代码在断点处停止时,我无法使用光标悬停在我的变量上以查看它们的值。以下是我纠正问题的方法:
- With the project open but not running make sure the Standard tool bar is displayed (it probably is because it's the default)
- Look at the drop down list in the toolbar that has the options Debug, Release, Configuration Manager. Select Debug from this list. Mine was set to Release
- 在项目打开但未运行的情况下,确保显示标准工具栏(可能是因为它是默认设置)
- 查看工具栏中包含调试、发布、配置管理器选项的下拉列表。从此列表中选择调试。我的设置为发布
回答by Daniel Reis
Visual Studio does not step into the code when it cannot load the symbols(.PDB file) of the DLL.
当 Visual Studio无法加载DLL的符号(.PDB 文件)时,它不会进入代码。
Below, there is a link to an article and some screenshots that explains how to discover where visual studio is trying to load the PDB files. Once you find out which directory you have, just copy the .pdb files there and Visual Studio will step into.
下面是一篇文章的链接和一些屏幕截图,它们解释了如何发现 Visual Studio 尝试加载 PDB 文件的位置。一旦你找到了你的目录,只需将 .pdb 文件复制到那里,Visual Studio 就会进入。
https://devblogs.microsoft.com/devops/understanding-symbol-files-and-visual-studios-symbol-settings/
https://devblogs.microsoft.com/devops/understanding-symbol-files-and-visual-studios-symbol-settings/
Modules Window --> Debug > Windows > Modules
模块窗口 --> 调试 > 窗口 > 模块
回答by Abhishek Tyagi
Try this:
尝试这个:
- Remove temporary ASP.NET files from the
%temp%location. - Clean and build projects in your solution one by one and then build your host and try debugging.
- 从该
%temp%位置删除临时 ASP.NET 文件。 - 在您的解决方案中一一清理和构建项目,然后构建您的主机并尝试调试。
It worked for me.
它对我有用。
回答by JMarsch
Is the WCF project a web application as well? Is ASP.NET debugging enabled for it? (right-click on the WCF project, go to Properties| Web)
I've also had this happen to projects when the references are messed up -- make sure that the reference from the web application is to the same copy of the project as the one in the solution.
Check the configuration manager (in Solution Explorer, right-click on solution| Configuration Manager), and make sure that both projects are building.
Sometimes the
.suofile gets corrupted, and you can get all sorts of weird behavior. You can try deleting it (make a backup copy if you are paranoid, see The evil suo file - fighting and winning with Visual Studio).
WCF 项目也是 Web 应用程序吗?是否为它启用了 ASP.NET 调试?(右键单击 WCF 项目,转到Properties| Web)
当引用搞砸时,我也遇到过这种情况——确保来自 Web 应用程序的引用与解决方案中的项目副本相同。
检查配置管理器(在解决方案资源管理器中,右键单击解决方案|配置管理器),并确保两个项目都在构建中。
有时
.suo文件会损坏,您可能会出现各种奇怪的行为。您可以尝试删除它(如果您偏执,请制作备份副本,请参阅邪恶的 suo 文件 - 与 Visual Studio 战斗并获胜)。
回答by Axxelsian
Your F11key may be rebound to something else. It may work if you click the step-into button in Visual Studio.
你的F11钥匙可能会反弹到别的东西上。如果您单击 Visual Studio 中的 step-into 按钮,它可能会起作用。
回答by huynhf
I had the same issue.
我遇到过同样的问题。
I wanted to step into a method that returns an IEnumeratorand I was calling it just by simple call (just the name of the method).
我想进入一个返回 an 的方法,IEnumerator我只是通过简单的调用(只是方法的名称)来调用它。
private void Start()
{
GetTagsFromCloud();
}
But since it runs in the background, it is better to call it with the following way.
不过既然是在后台运行,那么用下面的方式调用比较好。
private void Start()
{
StartCoroutine(GetTagsFromCloud());
}
回答by Tien
Shutdown Visual Studio then restart worked for me.
关闭 Visual Studio 然后重新启动对我有用。
回答by Stefanos Zilellis
If you can still step into using the toolbar but F11is dead, perhaps there is nothing wrong with Visual Studio but there is a higher priority consumer for the keystroke and never reaches Visual Studio.
如果您仍然可以使用工具栏但F11已死,则 Visual Studio 可能没有任何问题,但是击键的使用者具有更高的优先级,并且永远不会到达 Visual Studio。
You can verify that by using the key with another program, like another application or a game. If it does not work there either, then that is the case.
您可以通过将密钥用于其他程序(如其他应用程序或游戏)来验证这一点。如果它在那里也不起作用,那么就是这种情况。
It is good to give a try before messing with VS because it is faster and safer. You may end up reinstall the entire studio only to realize the issue is still there.
在使用 VS 之前尝试一下是很好的,因为它更快更安全。您最终可能会重新安装整个工作室,却发现问题仍然存在。
I had the same problem and in my case the higher priority consumer was Nvidia geforce experience where i had set F11as FPS indicator toggle. When i turn off the in-game overlay of this program(that is always active and ready for keystrokes to show fps, record, take snapshot, broadcast etc) F11worked like a charm after a PC restart.
我遇到了同样的问题,在我的情况下,更高优先级的消费者是 Nvidia geforce 体验,我已将其设置F11为 FPS 指示器切换。当我关闭此程序的游戏内覆盖(始终处于活动状态并准备好按键以显示 fps、录制、拍摄快照、广播等)时,F11在 PC 重新启动后就像一个魅力。
I assume that there are other always-on applications of same or similar role that may consume the keystroke.
我假设还有其他相同或类似角色的永远在线应用程序可能会消耗按键。

