P / call a 32-bit dll from a C # program running on an x64 machine

I have a C # program that I am compiling with all the default settings on an x64 computer.

I want a p / invoke DLL that I know is a 32-bit (unmanaged) C ++ DLL.

I can get this to work when my C # program is running on a 32-bit machine, but not on a 64-bit machine.

How can I indicate in the DllImport call that I am calling the 32-bit DLL?

An example of what I have:

[DllImport("test32bitdll.dll", SetLastError=true)]
public static extern void MyFunc();

I do not have the source code of the test32bitdll.dll file.

+5
source share
2 answers

Running 32-bit unmanaged code in a 64-bit process is not possible. Or vice versa. Available options:

  • EXE x86 Target Platform ""
  • ++ DLL x64. , , - , 32-
  • ++ DLL , 32- . , 64- 32- . , ,.NET Remoting, WCF .NET.

, , . .

+7

- exe "x86".

+6

All Articles