question

Upvotes
Accepted
646 6 13 25

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?

eikoneikon-com-api
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
39.2k 75 11 27

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.zip


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
39.2k 75 11 27

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.

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
646 6 13 25

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.

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
646 6 13 25

Any chance you have C++ console application example?

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
646 6 13 25

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

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
646 6 13 25

Alex, message pump/loop helped. Thank you

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.

Click below to post an Idea Post Idea