Well. You would certainly think that after installing VS 2005 and runnin it as many times as I have I would remember to set the MDA switches as one of my first actions. But no. It takes an error like this to remind me:
ContextSwitchDeadlock was detected
Message: The CLR has been unable to transition from COM context 0x1a7d00 to COM context 0x1a7e70 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.
And I'm supposed to be a professional. You would think I would remember to set the MDAs. Not! In fact, a lot of people I talked to at work had no clue what a MDA was or what it was used for! From MSDN - Diagnosing Errors with Managed Debugging Assistants:
Managed debugging assistants (MDAs) are debugging aids that work in conjunction with the common language runtime (CLR) to provide information on runtime state. The assistants generate informational messages about runtime events that you cannot otherwise trap. You can use MDAs to isolate hard-to-find application bugs that occur when transitioning between managed and unmanaged code. You can enable or disable all MDAs by adding a key to the Windows registry or by setting an environment variable. You can enable specific MDAs by using application configuration settings. You can set additional configuration settings for some individual MDAs in the application's configuration file. Because these configuration files are parsed when the runtime is loaded, you must enable the MDA before the managed application starts. You cannot enable it for applications that have already started.
So, how do you set them you ask? In this particular case you do the following:
- In Visual Studio, goto “Debug” -> “Exceptions…” menu (Ctrl-D, E)
- Open the Managed Debugging Assistants tree
- Uncheck ContextSwitchDeadlock
Hope that helps someone else. I also have it captured now so the next time I set up a machine I won't have to google the error to find the solution.