question

Upvotes
Accepted
3 1 1 7

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;

}

eikoneikon-com-apic#rt-get
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Upvotes
Accepted
4.6k 26 7 22

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.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Upvotes
3 1 1 7

thanks very much!!! we want to make the API synchronized, so we use ManualResetEvent. maybe it's the problem for being multi-thread. for the second question, we want implement not only RtGet but RData & RHistory. the native .NET Data API can only meet the RtGet requirement, so...

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

comapiusageexampledexmultithreading.zip

Attached is the sample for the ManualResetEvent in a Console application with EikonDesktopData API. Let me know if this helps!

I want to make this ACCEPT, thanks!!!

.NET Data API supports real-time and time series, but not the reference data. Also, if you want to use the intraday time series intervals (tick, 1 minute, etc), your only option is .NET.

.NET APIs for use in custom applications

I have seen the sample of reference data, it means the .NET Data API already supports reference data? but I have also checked NuGet, the API is not updated, I'm confused...

@dirkho not really, as this service provides only symbology conversion functionality.

Show more comments

On a second thought, are you trying to use it in the console application?

I have send you a mail with my sample code, I just have the problems in the console application.

Click below to post an Idea Post Idea