Unmanaged dll code

I have a C # application (.NET 3.5, VS2005 Professional) that uses an unmanaged 32-bit library written in C / C ++. The API I use is as follows:

void * Initialize (int x);

voic GetData (void *);

And this works when I run it on Windows XP 32bit, but on Windows XP64bit it throws an exception:

Unhandled exception: System.Reflection.TargetInvocationException: The exception was thrown by the target of the call. ---> System.BadImageFormatException: An attempt was made to load a program with the wrong format. (Exception from HRESULT: 0x8007000B) on Aktuelizator.CommonLibrary.InitializeRingBuffer (Int32 dim) on Aktuelizator.AktuelizatorWService.AktuelizatorWS..ctor ()

These unmanaged DLLs work under the 64-bit version of XP when called from the 32-bit unmanages writetn application in C / C ++.

Does anyone have any ideas?

+3
source share
3 answers

The assembly configuration platform is configured to "Any processor", that is, on a 64-bit OS it works like 64 bits, and you canโ€™t load the DLL. Instead, install x86, this will make it work as 32 bits, regardless of the OS, and your dll will load normally.

+2
source

, DLL 32 , 32-, 64- . , . , , . 32- DLL 32- . DLL 64- # .

+1

Check all the parameters that are defined as Int32, which should actually be IntPtr.

0
source

Source: https://habr.com/ru/post/1706515/


All Articles