keitn
keitn

Reputation: 1298

Call into 64bit Dephi DLL from C# on 64bit Machine

I my c# app I am trying to call into a Delphi DLL build as 64bit. I keep getting an error stating "An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B". I am running on a Windows 7 64 bit machine and have my C# project set to Any CPU.

API call

[DllImport("Cipher.dll", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.ThisCall)]
public static extern void Encrypt(StringBuilder szPlainText, StringBuilder  zCipherText);

Encrypt(plainString, encText);    

If the Delphi DLL was build as 32bit this call works fine. Any ideas?

Upvotes: 2

Views: 459

Answers (1)

Vilx-
Vilx-

Reputation: 106912

For some reason your app is not run as a 64-bit but rather a 32-bit process. If you need to do things like this, it's better to specify "x64" instead of "AnyCPU".

Upvotes: 4

Related Questions