Search code examples
c#visual-studio-2010visual-studio-debugging

Visual Studio 2010 extremely slow when populating ListBoxes while debugging


While debugging inside VS2010, programs naturally run a lot slower than otherwise.

However, lately my programs run at an indescribably slow rate if I'm updating the values of a ListBox. (Other controls may also be affected, I'm not sure... but ListBox is a sure thing).

Operations which happen in tiny fractions of a second outside the debugger, like adding 100 elements to a ListBox, can take as long as 3 to 5 minutes inside VS.

Clearly, this isn't normal behaviour.

I'm not sure when this started, but it hasn't been happening always. It started happening a couple of months ago. Maybe when I installed the service pack? I'm not sure.

When I look at the processes, msvsmon.exe is chewing through CPU.

Any ideas if there is some option somewhere that I may have changed which causes this? I'm trying to debug something with a ListBox containing 8,000 elements and It's just completely impossible.

Windows 7 x64, 4GB RAM, VS2010-SP1


Solution

  • Yes, I can see a lot of System.InvalidCastExceptions in the output window

    That's what causes the slow-down, the debugger does a lot of work when it processes an exception. Especially the remote debugger you are using now, required because your project's platform target is AnyCPU, adding the notification message to the Output window isn't cheap.

    You can't ignore this problem, it is not just a debugger artifact. Debug + Exceptions, tick the Thrown box for CLR Exceptions. The debugger will now stop when the exception is thrown. You'll need to fix that code.