Unable to cast COM object to Interface type

0

I have a DLL which is consumed by a 3rd party Application. I am trying to run a long running Task as Async which is failing due to error:-

"Unable to cast COM object of type 'System.__ComObject' to interface type 'IMSRelation.IJAssocRelation'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{609567C0-4ED3-11D1-B2B9-080036024603}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE))."

The code where it fails is:-

businessObject.Relationships

where businessObject is of type BusinessObject, code for which is

public class BusinessObject
{

    protected internal BusinessObject();

    protected internal BusinessObject(PrivateBusinessObject oBOP);

    public ReadOnlyCollection<RelationCollection> Relationships { get; }
}

Note:- This works fine if I don't use it inside (Async/Await or inside a new Thread) other processes. What I have looked till now is that the COM components needs to be marshaled before using them inside .NET Framework.

So can anyone suggest how to Marshal it, since BusinessObject Class does not implement any interface [As per my understanding Only interfaces can be Marshaled, Correct me if i am wrong].

Now obviously BusinessObject is Root Element and other classes implement it and those classes implement interfaces from where Relationships are accessed.

So do I need to get that particular interface from which I need to find the relationship and marshal it?? Please suggest a solution.

c#
asynchronous
com
asked on Stack Overflow Mar 5, 2019 by Shailesh Aggarwal • edited Mar 5, 2019 by Ehsan Sajjad

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0