Question

I have a C++ Class Library and an Windows application in C# using the library.

It works great on 32-bit Windows, but not on 64-bit Windows - BadImageFormatException occured.

I tried to change the platform of the C++ Class Library, however it can not changed to WIN64 from WIN32.

I think that one of the following questions can solve this problem.

  1. Is there a way to convert WIN32 Library to WIN64 Library?
  2. Is there another way to call C++ function on C# without using C++ Library?
  3. Is it possible to load WIN32 Library in 64 bit application?
Was it helpful?

Solution

Is there a way to convert WIN32 Library to WIN64 Library?

Rebuild (recompile) the library as a 64-bit library.

Is it possible to load WIN32 Library in 64 bit application?

No. From Programming Guide for 64-bit Windows:

... 32-bit processes cannot load 64-bit DLLs for execution, and 64-bit processes cannot load 32-bit DLLs for execution.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top