Disable the ContextSwitchDeadlock MDA error in VS .NET 2008
I had written a handy little VB.NET app that copied a list of scripts to a set of servers. Well, sometimes these scripts take a little while to finish executing (adding indexes to large tables), so my tool would come back with the following error when I'd run it in debug mode.
"ContextSwitchDeadlock was detected Message: The CLR has been unable to transition from COM context 0x54a5d8 to COM context 0x54a748 for 60 seconds. The thread that owns the destination context/apartment is most likely either doing a non pumping wait or processing a very long running operation without pumping Windows messages. This situation generally has a negative performance impact and may even lead to the application becoming non responsive or memory usage accumulating continually over time. To avoid this problem, all single threaded apartment (STA) threads should use pumping wait primitives (such as CoWaitForMultipleHandles) and routinely pump messages during long running operations."
Yeah. This is a very long and confusing error upon first glance. To get around this, I basically needed to disable the ContextSwitchDeadlock MDA exception error in .NET Studio 2008. MDAs are also known as "Managed Debugging Assistants" and are used as tools to help trap and resolve potential errors that the .NET Studio debugger detects. In this case, I get it... my scripts take a long time to apply sometimes... and that's OK. So here's what I did to disable this MDA exception.
- Added the "Exceptions..." menu command to my Debug menu via the Tools->Customize command.
- Clicked on the "Exceptions..." menu command and drilled down to the Managed Debugging Assistants.
- Unchecked the "Thrown" checkbox in ContextSwitchDeadlock.
- Clicked OK and I was good to go!
Tags: .net, COM, ContextSwitchDeadlock, debug, error, exception, halt, MDA, message, thrown, tools, trapping, visual studio, vs 2008
Comments
Got something to say?
