Visual Studio freezes on breakpoints

余生长醉 提交于 2020-01-04 13:05:33

问题


Since a week back I'm seeing a very annoying behavior from VS2010: As I'm debugging a project and the debugger stops on a breakpoint Windows freezes for almost ten seconds. I say "Windows freezes" because the mouse and keyboard are useless during this time period.

The problem only happens as I debug a specific project and I've tried it on two diffrent machines with the same result. The project is WPF and I do hook the keyboard at one point (not the mouse though) but that code hasn't been touched for months while the problem is just a week old.

I did install Telerik's big suite of everything (trial) just before this started to show so my first suspicion was Telerik's VS integration was the culprit. I uninstalled all Telerik VS integrations (the "JustXXX" products) but the problem remain.

I would be very greatful to anyone being abe to give a hint as to what might be going on here.

Thanks

EDIT 1: I have now tried building a new solution, moving all projects into it but the problem remains.

I then uninstalled everything Telerik, just to make sure, but this also was to no effect.

The next test was to load the exact same solution on a different machine and that did help. That machine has no 3rd party integrations with VS2010 except for reSHarper 6.1.

I have also analyzed the issue bit more and the typical scenario is that the first few times a breakpoint is hit the UI freezes for apeoximately ten seconds. Mouse/keyboard stops responding but the cursor keeps blinking in the code editor. The next few breakpoints does the same and often stepping from one line to another will cause a very long delay (no UI freeze though).

Also, if the first breakpoint is set very early in my application startup code I might not experience the problem. But as I continue to step through the code the debugger becomes more sluggish as the application initializes itself (in separate threads).

As I've said before this happens for a single application so the code is clearly related somehow.

Does anyone have good knowledge of how the debugger operates? Apart from the obvious steps needed whenever a breakpoint is set or the user steps from one line to another (refresh stack trace and watch windows) what is going on in the background that might freeze up everything and how is it possible?

My last hope is a complete reinstall of VS2010 but I hope I can solve this before that option is required.


回答1:


I have finally found the cause for this weird behavior. As I mentioned in the original post I do hook the keyboard (AND mouse, I had forgotten I did that) during the application's initialization in order to be able to detect user inactivity.

The monitoring takes place in a background thread that simply waits for an AutoResetEvent to discover user activity or inactivity. For some odd reason the AutoResetEvent.WaitOne(...) somehow affects the debugger. My current fix is to just avoid the wait if the debugger is attached.

I still cannot explain why this happens now. It has been working for a year but the cause for the problem is finally found and dealt with.

I have submitted my question to Microsoft, hoping to get a good explanation. If I do I will post it here.




回答2:


If you really have the problem with one Project / Solution you could try to create a new empty solution and add the project there, maybe this helps.

I don't really know much about the inner workings of Visual Studio (after all it must be one of the most complex pieces of software out there). But what I've learned is, that a reinstall often is the best and fastest solution (even if it takes an hour or two). Just make sure you backup any settings you don't want to lose.

Update:

I found this one here, maybe you've already found it too: http://connect.microsoft.com/VisualStudio/feedback/details/260864/visual-studio-debugger-occasionally-locks-up-the-entire-windows-gui

You could give it a try and disable the language bar.



来源:https://stackoverflow.com/questions/10817287/visual-studio-freezes-on-breakpoints

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!