开发者

How to get rid COM context error

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 contex开发者_如何学JAVAt 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.


Are you the owner of the COM object? Your workaround will either changing its threading model, or perhaps taking a good look here, especially the part about Release.


I used to get that error but only when I was in Debug mode. Do you get that error in release mode as well?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜