Calling convention error on COM call
I get "Run-Time Check Failure #0 - The value of ESP was not properly
saved across a function call."
when I call the method of the COM object. This problem happens only on
certain machines, not all.
In-proc server is FTM and client is STA. I suspect marshalling setting
and object creation. I have given details below, please let me know,
if catch anything wrong. This method just passes ENUM value. I am not
using custom proxy.
Client
-------------
CoInitializeEx(0,COINIT_APARTMENTTHREADED);
enum A valA = I_D;
ITest* pTest = 0;
CoCreateInstance();
pTest->SetMode(I_D); //Run-Time Check Failure #0 - The value of ESP
was not properly save
Server TestDLL.dll
--------------------------
0) Registry shows
[HKEY_CLASSES_ROOT\Interface\{F8D85DAA-098B-4947-8B08-E253A1D7499D}]
@="ITest"
[HKEY_CLASSES_ROOT\Interface\{F8D85DAA-098B-4947-8B08-E253A1D7499D}
\ProxyStubClsid]
@="{00020424-0000-0000-C000-000000000046}"
[HKEY_CLASSES_ROOT\Interface\{F8D85DAA-098B-4947-8B08-E253A1D7499D}
\ProxyStubClsid32]
@="{00020424-0000-0000-C000-000000000046}"
[HKEY_CLASSES_ROOT\Interface\{F8D85DAA-098B-4947-8B08-E253A1D7499D}
\TypeLib]
@="{315BE7EE-B39B-41F7-9B2A-9CF2824E6F27}"
1) _MERGE_PROXY preprocessor has been removed.
2) C++/H
STDMETHOD(SetMode)(enum A iMode );
STDMETHODIMP CTest::SetMode(enum A iMode)
{
m_A = iMode;
return 0;
}
3) IDL
enum A
{
I_A = -1,
I_B = 1,
I_C = 2,
I_D = 3
};
[
object,
uuid(F8D85DAA-098B-4947-8B08-E253A1D7499D),
dual,
nonextensible,
helpstring(""),
pointer_default(unique)
]
interface ITest : IDispatch
{
[id(3), helpstring("")] HRESULT SetMode(enum A iMode);
};
[
uuid(315BE7EE-B39B-41F7-9B2A-9CF2824E6F27),
version(1.0),
helpstring("Type Library")
]
library CTestLib
{
importlib("stdole2.tlb");
[
uuid(8B2E3F9E-AA9E-4579-BBC3-4B272DEF2520),
]
coclass CTest
{
[default] interface ITest;
};
};
RGS
-----
HKCR
{
TestDLL.CTest.1 = s 'CTest Class'
{
CLSID = s '{8B2E3F9E-AA9E-4579-BBC3-4B272DEF2520}'
}
TestDLL.CTest = s 'CTest Class'
{
CLSID = s '{8B2E3F9E-AA9E-4579-BBC3-4B272DEF2520}'
CurVer = s 'TestDLL.CTest.1'
}
NoRemove CLSID
{
ForceRemove {8B2E3F9E-AA9E-4579-BBC3-4B272DEF2520} = s 'CTest Class'
{
ProgID = s 'TestDLL.CTest.1'
VersionIndependentProgID = s 'TestDLL.CTest'
ForceRemove 'Programmable'
InprocServer32 = s '%MODULE%'
{
val ThreadingModel = s 'Free'
}
'TypeLib' = s '{315BE7EE-B39B-41F7-9B2A-9CF2824E6F27}'
}
}
}
HKCR
{
NoRemove AppID
{
'%APPID%' = s 'TestDLL'
'TestDLL.DLL'
{
val AppID = s '%APPID%'
}
}
}
Thanks
Ramesh