How to get rid COM context error

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

  1. livehed

    livehed New Member

    Joined:
    Sep 1, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Hi,

    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.

    Thanks.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice