Exception while calling CreateRData on Dex2.RData
Hello,
I am implementing the 'Dex2Example' example and the code throws an exception while trying to retrieve the data. While I can retrieve data using the form, as soon as trigger the CreateRData as a console application it throws the said exception:
An exception of type 'System.InvalidCastException' occurred in e_webservice.exe but was not handled in user code.
It's not possible to associate an object COM of type 'System.__ComObject' to the interface 'Dex2.IDex2Mgr3'. This operation has failed because the call QueryInterface in the COM component (...) RESULT: 0x80004002 (E_NOINTERFACE)
The excpetion is thrown on the line
MyRData = MyDex2Mgr.CreateRData(MyDex2Cookie);
mydex2cookie value is 1 and the connection status is 'suceeded'.
The MyDex2Mgr initialization is as follows:
public void CreateDex2Mgr()
{
// Create the Dex2 manager
MyDex2Mgr = MyEikonDesktopDataAPI.CreateDex2Mgr();
// Initialize the Dex2 manager and retrieve a session cookie
if (MyDex2Mgr != null)
MyDex2Cookie = (MyDex2Mgr as IDex2Mgr2).Initialize(DEX2_MetadataCaller.DE_MC_ADC_UNKNOWN);
}
Cheers,
Duarte
Answers
-
Hi @duarte_quintelauarte, there are a few things that you should do to make sure that your code will work just fine in the console application:
- make sure that your console app is running in the single-threaded apartment mode, you can add [STAThread] attribute to your static void Main() method;
- since the API is COM, you will need to run the event loop manually, as it is not present in the console apps; the easiest way is to reference the WindowsBase.dll assembly, and add the following routine to your class Program:
#region Dispatcher
public static DispatcherFrame Frame; //the object is required in order to release the Windows message pump while executing asynchronous calls.
public static void PushDispatcherFrame()
{
Dispatcher.PushFrame(GetDispatcherFrame());
}
public static void StopMessagePump()
{
Frame.Continue = false;
Frame = null;
}
public static DispatcherFrame GetDispatcherFrame()
{
return Frame ?? (Frame = new DispatcherFrame());
}
#endregion- after you have done this, you will need to call Program.PushDispatcherFrame() manually every time you execute any calls, and Program.StopMessagePump() when you receive a result;
Let me know if it works.
1 -
Hello @Zhenya_Kovalyov
I've implemented the Dispatcher Frames method and the [STAThread] attribute on the main function.
Now, I've got another error on
MyDex2Cookie = (MyDex2Mgr as IDex2Mgr2).Initialize(DEX2_MetadataCaller.DE_MC_ADC_UNKNOWN);
The exception is as follows:
An unhandled exception of type 'System.Runtime.InteropServices.COMException' in eikon.exe
Class not registered (Exception from HRESULT: 0x80040154
(REGDB_E_CLASSNOTREGI have the following dll's referenced in my project:
- Interop.Dex2
- Interop.EikonDesktopDataAPI
Thank you for your time,
Duarte
0 -
It still looks as if you are activating and using the object in different threads. Could you drop me an email at evgenij.kovalev@tr.com and we can have a look at your code together.
0
Categories
- All Categories
- 6 AHS
- 39 Alpha
- 161 App Studio
- 4 Block Chain
- 4 Bot Platform
- 16 Connected Risk APIs
- 47 Data Fusion
- 30 Data Model Discovery
- 608 Datastream
- 1.3K DSS
- 577 Eikon COM
- 4.9K Eikon Data APIs
- 7 Electronic Trading
- Generic FIX
- 7 Local Bank Node API
- Trading API
- 2.7K Elektron
- 1.3K EMA
- 236 ETA
- 519 WebSocket API
- 33 FX Venues
- 10 FX Market Data
- 1 FX Post Trade
- 1 FX Trading - Matching
- 12 FX Trading – RFQ Maker
- 5 Intelligent Tagging
- 2 Legal One
- 20 Messenger Bot
- 2 Messenger Side by Side
- 9 ONESOURCE
- 7 Indirect Tax
- 59 Open Calais
- 264 Open PermID
- 39 Entity Search
- 2 Org ID
- PAM
- PAM - Logging
- 8.4K Private Comments
- 6 Product Insight
- Project Tracking
- ProView
- ProView Internal
- 20 RDMS
- 1.4K Refinitiv Data Platform
- 367 Refinitiv Data Platform Libraries
- 3 Refinitiv Due Diligence
- LSEG Due Diligence Portal API
- 3 Refinitiv Due Dilligence Centre
- Rose's Space
- 1.1K Screening
- 18 Qual-ID API
- 13 Screening Deployed
- 23 Screening Online
- 10 World-Check Customer Risk Screener
- 990 World-Check One
- 44 World-Check One Zero Footprint
- 45 Side by Side Integration API
- Test Space
- 3 Thomson One Smart
- 1.2K TR Internal
- Global Hackathon 2015
- 2 Specialists Who Code
- 10 TR Knowledge Graph
- 150 Transactions
- 142 REDI API
- 1.7K TREP APIs
- 4 CAT
- 21 DACS Station
- 117 Open DACS
- 1.1K RFA
- 103 UPA
- 172 TREP Infrastructure
- 224 TRKD
- 886 TRTH
- 5 Velocity Analytics
- 5 Wealth Management Web Services
- 59 Workspace SDK
- 9 Element Framework
- 5 Grid
- 13 World-Check Data File
- Yield Book Analytics
- 46 中文论坛