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.
References:

Comments