views:

1278

answers:

7

Sometimes, while I am debugging a c# application, I will hit a break point and when I try to continue, step or step into, it just does nothing. 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.

+1  A: 

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? Either of these situations would cause the debugger to freeze while the external code was executing.

John Sibly
it's not freezing while the external code is executing. It is often a very simple line and it never starts back up again.
Kevin
+1  A: 

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.

Daok
A: 

My psychic debugger says that you're missing symbols for something and that VS is hitting the network trying to look them up. Try setting your symbol path to something weird like C:\foo.

Paul Betts
+2  A: 

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.

Sean
A: 

dead-lock seems likely in your case. Press the pause button and look at the threads view next time it happens.

Robert Gould
A: 

I have seen this type of behavior when my DB was being very slow, NHibernate is trying to write to it under the hood, and the whole debugger gets locked randomly when the DB gets pegged.

A: 

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")]
  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.

Please let us know if this is also your case.