Unable to cast COM object of type 'System.__ComObject' to interface type

When I implement the RtGet function by CSharp (by using Interop.EikonDesktopDataAPI and Interop.RTX), I meet an exception "Unable to cast COM object of type 'System.__ComObject' to interface type 'ThomsonReuters.Interop.RTX.IAdxRtList'". What's happened?

public List<RicItem> Get(List<RicItem> ricData)

{

this.ricData = ricData; this.ricData.ForEach(ric => {this.adxRtList.RegisterItems(ric.Ric, ric.Field); });

this.adxRtList.StartUpdates(RT_RunMode.RT_MODE_ONUPDATE); syncMgr.WaitOne();

return this.ricData;

}

Best Answer

  • It is difficult to say without the full code, and it can be more than one issue. However, a good start will be to check if you are accessing and controlling adxRtList from the same thread it was created in. The COM objects should be created in a thread that runs in the single-threaded apartment mode (STA).

    On a separate note, is there a reason why you are not using the native .NET Data API? Check out the tutorial.

Answers