I'm having an issue calling a COM object function from .NET C# client program. The COM object is written in C++ unmanaged. The problem only appears when I'm calling from a worker thread, it works fine if I call it from the UI thread. This is the error:
Unable to cast COM object of type 'gvAgileFileReaderLib.gvAgileFileReaderClass' to interface type 'gvAgileFileReaderLib.IgvMpiRead'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{616B5C39-C7FB-4C8C-85D4-27559DD83304}'
failed due to the following error: Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL)).
I have tried the following methods but all of them fails:
1) Create the COM object on UI thread, and call its function via its interface (IgvMpiRead) in the worker thread
2) Create the COM object on the worker thread & access its function from worker thread
3) Tried with worker thread set to STA & MTA
I need to use the COM function is a worker thread to prevent a long processing from holding up my UI, but it just doesn't work when I try to call the COM function inside the worker thread.
The weird thing is that doing the same from a unmanaged C++ client works fine (I can create the com object on UI, and then call its function from worker thread). Is this problem caused by inter
View Complete Post