2

I must call a 32bit unmanaged DLL from an external provider from my C# WinForms project.

However I must build my C# project as "Any CPU" to take advantage of the greater memory on 64bit computers.

Therefore, when I try to call the 32bit DLL from a machine running 64bit, I get this error:

BadImageFormatException : An attempt was made to load a program with an incorrect format

Changing the build to target x86 is not an option for us.

We do not have any ability to modify the external DLL itself.

How can I get around this error?

Brendan Hill
  • 3,406
  • 4
  • 32
  • 61

1 Answers1

1

If you can't change your project to x86 only then you cannot call the 32bit DLL directly. You'll have to create a 32 bit process that calls the DLL then use some inter-process communication to talk between your 64 bit process and the 32 bit hosting processing.

shf301
  • 31,086
  • 2
  • 52
  • 86