Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Calling convention error on COM call

6 views
Skip to first unread message

asno...@gmail.com

unread,
Oct 21, 2009, 9:17:42 PM10/21/09
to
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

Igor Tandetnik

unread,
Oct 21, 2009, 10:44:55 PM10/21/09
to
asno...@gmail.com wrote:
> I get "Run-Time Check Failure #0 - The value of ESP was not properly
> saved across a function call."
>
> 3) IDL
> enum A

Try putting a [v1_enum] attribute on your enum.
--
With best wishes,
Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not necessarily a good idea. It is hard to be sure where they are going to land, and it could be dangerous sitting under them as they fly overhead. -- RFC 1925

asno...@gmail.com

unread,
Oct 22, 2009, 12:05:33 PM10/22/09
to
Thanks Igor for helping, your suggestion helped resolve it.


Regards,
Ramesh


On Oct 21, 10:44 pm, "Igor Tandetnik" <itandet...@mvps.org> wrote:

asno...@gmail.com

unread,
Oct 23, 2009, 1:22:43 PM10/23/09
to
This problem is showing up at different places now. Till now, "RunTime
Erro# Wrong calling convention" was coming when I called my own In-
proc server( i solved this by changing Server), but now I am seeing
same issue when I call MAPI interface(Microsoft Library).

http://doc.ddart.net/msdn/header/include/mapidefs.h.html
If you can understand, here is the H file for the method that I am
calling, GetRecipientTable(). This code worked fine with VC6.0, now we
are using it in VS2008. Worst is this does not happen with every
machine. Calling process is entering in to STA. Something fundamental
seems to be going wrong here and that is affecting COM methods
invocation. Solution could be as just changing compiler setting but I
have no clue. VS setting says __cdecl by default but every COM method
specifies calling convention.

Thanks
Ramesh

On Oct 22, 12:05 pm, "asnowf...@gmail.com" <asnowf...@gmail.com>
wrote:

> > With sufficient thrust, pigs fly just fine. However, this is not necessarily a good idea. It is hard to be sure where they are going to land, and it could be dangerous sitting under them as they fly overhead. -- RFC 1925- Hide quoted text -
>
> - Show quoted text -

0 new messages