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
Read More...