PInvoke Unbalance Stack

Good day,

I am working on a dll that CORBA can use to communicate with an application that is known on the network. The code works fine if I run it as a C ++ console application. However, I am stuck with exporting methods as dlls. It seems that the methods are being exported perfectly, and if I call the method without parameters, it works as expected. I was hanging over passing a C # string to a C ++ method.

My C ++ method header looks like this:

bool __declspec(dllexport) SpiceStart(char* installPath)

The import code of my C # DLL is as follows:

[DllImportAttribute("SchemSipc.dll", CharSet=CharSet.Ansi)]
private static extern bool SpiceStart(string installPath);

I call the method as follows:

bool success = SpiceStart(@"c:\sedatools");

The SpiceStart call throws a PInvokeStackImbalance exception, which is "probably because the PInvoke managed signature does not match the unmanaged target signature."

- ? char * , . , dll #.

,

Giawa

+5
1

. ++ stdcall:

extern "C" bool __declspec (dllexport) __stdcall SpiceStart (char * installPath)

+10

All Articles