简体   繁体   English

为什么Visual Studio在调试时停止?

[英]Why does Visual Studio stall while debugging?

Sometimes, while I am debugging ac# application, I will hit a break point and when I try to continue, step or step into, it just does nothing. 有时候,当我调试ac#应用程序时,我会遇到一个断点,当我尝试继续,步入或进入时,它什么也没做。 The yellow line highlighting the current line goes away, but it never reaches the next line. 突出显示当前行的黄线消失,但它永远不会到达下一行。 The app is still frozen like I am on a breakpoint and I can do nothing but hit the stop debugging button and restart. 应用程序仍然像我在断点处一样冻结,除了点击停止调试按钮并重新启动,我什么也做不了。 This doesn't happen all the time, but once it starts on an app it seems like it always happens after that for that app. 这不会一直发生,但一旦它在应用程序上启动,它似乎总是发生在该应用程序之后。 I have found that adding the following code just before the class declaration "fixes" the problem for that app, but am very curious as to why this is happening. 我发现在类声明之前添加以下代码“修复”该应用程序的问题,但我很好奇为什么会发生这种情况。

[System.Diagnostics.DebuggerDisplay("Form1")]

Additional details: I have not noticed any kind of pattern as to what the particular line does when it freezes. 其他细节:我没有注意到特定线冻结时的任何模式。 Most of the apps I write use threading, so there is a decent chance this is happening within a thread every time. 我编写的大多数应用程序都使用线程,因此每次在一个线程中发生这种情况的可能性很小。

I've seen stalling problems where the debugger is trying to evaluate the variables shown in the Auto/Local windows. 我已经看到了调试器试图评估自动/本地窗口中显示的变量的停滞问题。 If the evaluation is complicated then it can cause significant stalls. 如果评估很复杂,那么它可能会导致严重的停顿。

You can turn the auto-evaluation off through Tools|Options and it does make a big difference. 您可以通过工具|选项关闭自动评估,它确实会产生很大的影响。

I have come across with this kind of behavior, though this is my first time. 我遇到过这种行为,虽然这是我的第一次。

I have got through this problem, by two ways 我通过两种方式解决了这个问题

  1. Your way of putting this attribute, [System.Diagnostics.DebuggerDisplay("Form1")] 你放置这个属性的方法,[System.Diagnostics.DebuggerDisplay(“Form1”)]
  2. Turning off Tools->Options->Debugging->General->Enable Property evaluation and other implicit function calls. 关闭工具 - >选项 - >调试 - >常规 - >启用属性评估和其他隐式函数调用。

I am still debugging my code but It seems to me that some of the Autos evaluation is failing (possibly throwing an exception), which is possibly crashing the debugger. 我仍在调试我的代码,但在我看来,一些Autos评估失败(可能抛出异常),这可能会使调试器崩溃。

Please let us know if this is also your case. 如果您也是这样,请告诉我们。

What sort of code are you debugging? 你在调试什么样的代码?

When you "step into" are you calling your own .NET code, or calling a native library, or an external assembly that you don't have the pdb files for? 当你“步入”你是在调用自己的.NET代码,还是调用本机库,或者你没有pdb文件的外部程序集? Either of these situations would cause the debugger to freeze while the external code was executing. 这些情况中的任何一种都会导致调试器在外部代码执行时冻结。

If you debug multithreaded application you might be changing of thread. 如果您调试多线程应用程序,您可能正在更改线程。 You can switch between Thread with the "Thread windows" while debugging to be able to see again where the debug yellow line is. 您可以在调试时使用“Thread windows”在Thread之间切换,以便能够再次查看调试黄线的位置。

My psychic debugger says that you're missing symbols for something and that VS is hitting the network trying to look them up. 我的通灵调试器说你错过了某些东西的符号,并且VS正在试图查找它们。 Try setting your symbol path to something weird like C:\\foo. 尝试将符号路径设置为奇怪的东西,如C:\\ foo。

dead-lock seems likely in your case. 你的情况似乎很可能是死锁。 Press the pause button and look at the threads view next time it happens. 按下暂停按钮,下次发生时查看线程视图。

当我的数据库非常慢时,我已经看到了这种行为,NHibernate试图在引擎盖下写入它,并且整个调试器在数据库被挂钩时被随机锁定。

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

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