1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How to get rid COM context error

Discussion in 'C#' started by livehed, Sep 1, 2010.

  1. livehed

    livehed New Member

    Sep 1, 2010
    Likes Received:
    Trophy Points:

    Am working on a windows form application which uses interop to call a COM dll. I keep getting this error in the app method where the flow is like this:

    1.Fetch about 7 records[R] from database 2.For each of this record,app instantiates a COM class using Interop and does some processing/calculation using the same. 3.Then the app fetches about 750 records for each of this record R. 4.App then updates back data in database for each record in step 3.

    ContextSwitchDeadlock was detected
    Message: The CLR has been unable to transition from COM context 0x1c8be8 to COM context 0x1c8a78 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.
    FYI, I'm using System.Runtime.InteropServices.Marshal.ReleaseComObject to release the COM object instance. Any idea, how to get rid of this?Please suggest.


Share This Page