Les and Folks, I have some useful information on this I hope.
I had to compile the C# app as platform x86 to consume the Borland XE5 C++
DLL's functions, but I'm guessing the author just used the defaults and
didn't specifically force me to do that.
The C++ function was defined as __declspec(dllexport) and the managed
runtime Exception implied I was "almost" calling the function. This simple
change made it work okay:
[DllImport("foo.dll", CallingConvention=CallingConvention.Cdecl)]
Bring backa memory from the 1990s. We still have to check that strings are
marshalled back-and-forth correctly.
Greg
On 8 October 2013 11:29, Les Hughes <[email protected]> wrote:
> Greg Keogh wrote:
>
>> Folks, I've got some DLLs written in Borland C++ with functions that I
>> have to import for use in some C# code. I can see the functions inside the
>> DLLs using depends.exe, but I can't get the signatures correct and I get
>> "unbalanced stack" errors runtime due to mismatching signatures.
>> Is there some technique I can use to convert the DLL functions into
>> correctly matching methods with [DLLImport]? The weak link at the moment is
>> the human one, me.
>> Greg K
>>
>
> Solution is to destroy the weak link! Use a robot!
>
> Have you tried this:
> https://clrinterop.codeplex.**com/<https://clrinterop.codeplex.com/>It's
> *meant* to do make things easier.
>
> Another thought: Could it be that your app is expecting 64-bit integers
> from a 32-bit dll?
>
> Cheers,
> --
> Les Hughes
> [email protected]
>
>
>