ContextSwitchDeadLock erorr while debugging
While debugging a managed code batch process today I ran into VS throwing a 'ContextSwitchDeadlock MDA' error. The debugger was attached to several long running process's and towards the end of the cycle VS was reporting this issue. As Mike Stall reports it seems to be caused by the thread running the managed code I am debugging timing out but the unmanaged thread seeing not seeing it as dead. Why the managed code I am running times out in the debugger thread I am not clear about. It seems like that the debugger has a fixed response to all break points that starts at execution time, as each step I am debugging goes off to the database, waits a while and then comes back, it eats into this time. Eventually the debugger thread times out and the ContextSwitchDeadlock error occurs. You can't stop this kind of error (although I do wonder if the time out value on the debugger thread could be adjusted) but you can disable the warning.
Two tips I extracted from this thread is
First you don't already have it (Debug - Exceptions) obtain the debug exceptions window (right click tool bar - customize - debug and drag exceptions into the debug menu).
Select from Debug - Exceptions - Managed Debugging Assistants and disable ContextSwitchDeadlock.
I had no luck with trying to disable this via reg keys and config files but that is suggested in the MDA help files.