Error on Dex2Mgr2 initialize
Hello,
I'm trying to mimic some parts of C++ Dex2Samples example in my console application.
This function:
HRESULT CCppEikonnectDlg::CreateDex2Mgr()
{
// Create the Dex2 manager
HRESULT l_hr= g_MyEikonDesktopDataAPI->CreateDex2Mgr((IUnknown **)&g_MyDex2Mgr);
if (l_hr==S_OK)
{
g_MyDex2MgrADC = g_MyDex2Mgr;
// Initialize the Dex2 manager and retrieve a session cookie
CComVariant l_EmptyVar;
l_EmptyVar.vt=VT_ERROR;
l_EmptyVar.scode=DISP_E_PARAMNOTFOUND;
l_hr = g_MyDex2MgrADC->Initialize(Dex2Lib::DEX2_MetadataCaller::DE_MC_ADC_POWERLINK, l_EmptyVar, &g_MyDex2MgrCookie);
if (l_hr!=S_OK)
{
// Release the Dex2 manager
g_MyDex2Mgr.Release();
}
}
return l_hr;
}
throws because of the line : g_MyDex2MgrADC = g_MyDex2Mgr;. g_MyDex2MgrADC ends up as NULL.
And it happens because of QueryInterface fails inside of atlcomcli.h
However, Dex2Samples project runs fine.
What am I doing wrong?
Best Answer
-
I don't quite see how multithreaded concurrency helps to receive events from Eikon. What's different between winforms and console is that in winforms the message pump required to receive COM events is automatically started on the GUI thread. In a console you need to implement a message loop on the thread that creates Eikon COM APIs objects. Btw Eikon COM APIs are single apartment threaded.
I'm afraid I don't have a console C++ example using DEX2. I have attached a console example using AdfinX Real-Time library. You can check it out to see an example of message loop implementation allowing application to process Eikon COM APIs events.
This said I don't think any of the above is related to the QueryInterface method failing (do I understand correctly that the method returns E_NOINTERFACE in your console app)? Have you included Dex2.dll.manifest file along with Dex2.dll in your project?
eikoncomconsoleapp.zip0
Answers
-
These are all wild shots, but can you see if COM object in g_MyDex2Mgr is created successfully? If not, make sure that at the time you call this function your application is already connected to Eikon (i.e. that g_MyEikonDesktopDataAPI.Status returns EikonDesktopDataAPILib::Connected). Finally make sure you compile your application as 32-bit. Eikon COM APIs are 32-bit and cannot be used in 64-bit processes.
0 -
1. yes, g_Dex2Mgr is created without an error
2. And its creation happens after the app is connected to the Eikon (I stop main thread until I get StatusChanged callback).
3. yes, I build it as 32bit application
The only differences between sample project and mine are :
I have to do:
::CoInitializeEx(NULL, COINIT_MULTITHREADED);
instead of
::CoInitialize(NULL);
Otherwise it does not receive callbacks (events) from Eikon.
Second, it's console application, but not winforms.
As I mentioned before, the problem happens here:
g_Dex2MgrADC = g_Dex2Mgr;
g_Dex2MgrADC becomes NULL because operator= in atlcomcli.h checks if it can execute QueryInterface on the g_Dex2Mgr.. and for some reason, it cannot and assign NULL to g_Dex2MgrADC.
0 -
Any chance you have C++ console application example?
0 -
Alex,
Thank you for your help again. Below is my answers.
1. COINIT_MULTITHREADED. Looks like it does not need message loop
2. Based on what I found in different docs and articles , if server and client uses different apartment types , it may lead to E_NOINTERFACE as I get in my app.
3. this call l_hr = g_Dex2Mgr->QueryInterface( &g_Dex2MgrADC ); returns E_NOINTERFACE. Might be because of #3.
4. I followed the ReadMFirst and copied all the files (including manifest) to my 3rdparties folder.
Let me check the example you've attached and I will post back the results.
Thanks
0 -
Alex, message pump/loop helped. Thank you
0
Categories
- All Categories
- 3 Polls
- 6 AHS
- 36 Alpha
- 166 App Studio
- 6 Block Chain
- 4 Bot Platform
- 18 Connected Risk APIs
- 47 Data Fusion
- 34 Data Model Discovery
- 687 Datastream
- 1.4K DSS
- 623 Eikon COM
- 5.2K Eikon Data APIs
- 11 Electronic Trading
- Generic FIX
- 7 Local Bank Node API
- 3 Trading API
- 2.9K Elektron
- 1.4K EMA
- 255 ETA
- 557 WebSocket API
- 38 FX Venues
- 14 FX Market Data
- 1 FX Post Trade
- 1 FX Trading - Matching
- 12 FX Trading – RFQ Maker
- 5 Intelligent Tagging
- 2 Legal One
- 23 Messenger Bot
- 3 Messenger Side by Side
- 9 ONESOURCE
- 7 Indirect Tax
- 60 Open Calais
- 276 Open PermID
- 44 Entity Search
- 2 Org ID
- 1 PAM
- PAM - Logging
- 6 Product Insight
- Project Tracking
- ProView
- ProView Internal
- 22 RDMS
- 1.9K Refinitiv Data Platform
- 685 Refinitiv Data Platform Libraries
- 4 LSEG Due Diligence
- LSEG Due Diligence Portal API
- 4 Refinitiv Due Dilligence Centre
- Rose's Space
- 1.2K Screening
- 18 Qual-ID API
- 13 Screening Deployed
- 23 Screening Online
- 12 World-Check Customer Risk Screener
- 1K World-Check One
- 46 World-Check One Zero Footprint
- 45 Side by Side Integration API
- 2 Test Space
- 3 Thomson One Smart
- 10 TR Knowledge Graph
- 151 Transactions
- 143 REDI API
- 1.8K TREP APIs
- 4 CAT
- 27 DACS Station
- 121 Open DACS
- 1.1K RFA
- 105 UPA
- 194 TREP Infrastructure
- 229 TRKD
- 918 TRTH
- 5 Velocity Analytics
- 9 Wealth Management Web Services
- 91 Workspace SDK
- 11 Element Framework
- 5 Grid
- 18 World-Check Data File
- 1 Yield Book Analytics
- 48 中文论坛