Posts Tagged STA
An invalid VARIANT was detected during a conversion from an unmanaged VARIANT to a managed object – C#
I have got this exception after I fixed this error, please check this post and read the following…!
“An invalid VARIANT was detected during a conversion from an unmanaged VARIANT to a managed object. Passing invalid VARIANTs to the CLR can cause unexpected exceptions, corruption or data loss.”
Just go to the Debug menu in Visual studio and select Exceptions
Click and expand the Manage Debugging Assistants
Find the Invalid Variant node and uncheck the Thrown check box.
Click Ok and run the application, That’s all! Happy Programming..! If you want to read more about this issue, just read this post! 🙂
The CLR has been unable to transition from COM context 0xXXXXXXX to COM context 0xYYYYYYY for 60 seconds – C#
Few months ago, I was developing a small windows application which gathers data from Active Directory(AD) and dumping into a SQL database table. There were around 18 to 20,000 records involved in the process. After developing and testing components with few data, everything was okay but when I run the application I got following error message:
“The CLR has been unable to transition from COM context 0x2297ce0 to COM context 0x2297f30 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.”
I didn’t want to spend too much time with this error and I have found the quick fix from this site, if you want to know more about this please read there. 😉
Here are the steps to fix this error;
Step 1: Go to Debug –> Exceptions in Visual Studio 2010 (I was using 2010)
Step 2: Click on Managed Debug Assistants
Step 3: Un-check the ContextSwitchDeadlock and click OK
That’s all, the problem was fixed but I have got an other error, please see the same kind of solution here.