API Support Forum
OEC API > API Support > GAIN API COM Example problem
Author Topic: GAIN API COM Example problem
(3 messages, Page 1 of 1)
Moderators: VPfau
Posts: 38
Joined: May 03, 2018

Posted: Jul 15, 2020 @ 10:24 AM             Msg. 1 of 3
I am having a problem with the CppCOMSample solution as follows:

1) I downloaded and installed the newest versions of the 32 and 64 bit API for COM users from https://gainfutures.com/gainfuturesapi/documentation as well as the newest version of the CppCOMSample solution.

2) I verified with regedit.exe that the libid key 20A98AD2-2C0F-4192-A53D-0F6189ED5B2B is pointing to the proper directories for the 32-bit and 64-bit versions.

3) I loaded the CppCOMSample with Visual Studio 2019 and built the 32-bit Debug application. When I run it and connect with my username and password, it connects properly and I am able to perform a Symbol Lookup operation with no errors. If I attempt to connect with a known incorrect username and/or password, CCppCOMSampleDlg::OnLoginFailed is called with failReason set to FailReason_InvalidUserOrPassword (0).

4) I built the 64-bit Debug version and executed it. When I attempt to logon, one of two things happens:
a) Most often, _Release() method in comip.h is called with a read access violation exception. I'll include the call stack at the bottom of this message.
b) Less often, CCppCOMSampleDlg::OnLoginFailed is called with failReason set consistently to 1366336 (decimal) - this bogus failReason code may be a separate and unrelated bug.

5) I get the same result for the 64-bit version when I attempt to logon with a known incorrect username/password.

6) Chris M. has verified that my account is valid.

Best regards,
Scott Watson

When the exception is thrown as described in 4a above, the call stack looks like:
> CppCOMSample.exe!_com_ptr_t>::_Release() Line 969 C++
CppCOMSample.exe!_com_ptr_t>::~_com_ptr_t>() Line 224 C++
CppCOMSample.exe!CCppCOMSampleDlg::OnAccountSummaryChanged(_com_ptr_t> client, _com_ptr_t> account, _com_ptr_t> currency) Line 315 C++
[External Code]
CppCOMSample.exe!AfxInternalPumpMessage() Line 183 C++
CppCOMSample.exe!CWinThread::PumpMessage() Line 900 C++
CppCOMSample.exe!AfxPumpMessage() Line 190 C++
CppCOMSample.exe!CWnd::RunModalLoop(unsigned long dwFlags) Line 4661 C++
CppCOMSample.exe!CWnd::CreateRunDlgIndirect(const DLGTEMPLATE * lpDialogTemplate, CWnd * pParentWnd, HINSTANCE__ * hInst) Line 470 C++
CppCOMSample.exe!CDialog::DoModal() Line 633 C++
CppCOMSample.exe!CCppCOMSampleApp::InitInstance() Line 63 C++
CppCOMSample.exe!AfxWinMain(HINSTANCE__ * hInstance, HINSTANCE__ * hPrevInstance, char * lpCmdLine, int nCmdShow) Line 37 C++
CppCOMSample.exe!WinMain(HINSTANCE__ * hInstance, HINSTANCE__ * hPrevInstance, char * lpCmdLine, int nCmdShow) Line 26 C++
[External Code]
Posts: 41
Joined: Aug 24, 2017

Posted: Jul 24, 2020 @ 11:46 AM             Msg. 2 of 3

We have reproduced your issue. It looks like in x64, COM is not sending event arguments pointers correctly. We will investigate a fix.

Regarding 4b -- I suspect this is happening when you are debugging long enough that the API fails the heartbeat and disconnects.
Posts: 41
Joined: Aug 24, 2017

Posted: Aug 05, 2020 @ 01:51 PM             Msg. 3 of 3
An update has been pushed to the comapisamples repo to fix x64 event argument references. Please try again.