views:

166

answers:

1

Hello,

I have a strange error:

Managed Debugging Assistant 'ContextSwitchDeadlock' has detected a problem in 'C:\Documents and Settings\Lena G\My Documents\SchoolStuff\IR Information\Home Work\FianlProject\finalProject\finalProject\bin\Debug\finalProject.vshost.exe'. Additional Information: The CLR has been unable to transition from COM context 0x3407968 to COM context 0x3407ad8 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.

In this error I can just continue the run or break and if I continue then it runs ok but still that worries me. I have a program that I read an xml file that has some texts, place the words in a hashtable and then write from the hash to a regulat text file.

Appriciate if someone can help me to solve this problem.

Thanks in advance,

Lena

A: 

Phew! The Managed Debugging Assistants are wonderful, but they do give verbose exception messages. In this case Visual Studio is warning you that a thread in your application that's doing a COM call isn't playing "nice" and responding properly to Windows messages.

You can continue the run and all should be well - but it makes sense to investigate what's causing the problem in the first place.

What does your code do, precisely? How does it read the XML file? How large are the files?

If it's just sitting in a loop parsing an XMLDocument then I'd be surprised to see this error. You might (shudder) want to consider checking your Windows event log to see if there's any bad sectors on your hard disk...

On the other hand, if you're using background threads at all, then it might be that there's an issue with resource starvation or that there's a blocking call sitting around somewhere that's not yielding frequently enough.

Jeremy McGee