I am writing a program in .NET 3.5, which in some places should exit and execute code from the hardware APIs. All this is good, and works on 32-bit Windows 7, Windows XP, etc. The problem is related to Windows 7 n 64 bit.
I compile to "Any processor" and it works on 64-bit on Windows 7 bit 64 bit. So, in order to interact with this one hardware, I had to write my own wrapper library in unmanaged C ++.
So, after I had everything working in 32 bits, I switched the switches to 64 bits, and that is the problem. The problem I am facing is pretty much the exact opposite of the stack overflow question "An attempt was made to load a program with the wrong format," even if the platforms are the same ... In this question, he is trying to get his code to work in 32 bits (make it ) on Windows 7.
OK, now I do not want to do this, since there is a 64-bit API for this hardware. So, I compiled my code in 64-bit mode, and then after a lot of trial and error, I got it LINK correctly in 64-bit mode, and I have the 64-bit PURE CLEAR library, and it Depends.execonfirms this. Now Depends.exealso displays the provider .dll file as pure 64-bit. This is good, because the first time the code didn't work, I started researching with the manufacturer, and they updated their code a bit with my help, or I have to say with my questions ... :)
, , , . DLL , HW API.dll ( ++) .NET , P/Invoke 64- ...
, , :
[DllImport("xBiometrics.dll", ExactSpelling=true, SetLastError=true)]
[return: MarshalAs(UnmanagedType.I4)]
public static extern Int32 bioScanOpenDevice();
, , .NET :
"System.BadImageFormatException:
An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)"
, -, - 32- ... ? , , , DLL , 64 , .NET 64-, "Any CPU". ...
- ? , , P/Invoke 64 - ? , ?
, , ? 64- .NET 64- DLL ? DLL 64- DLL ? , 64- DLL DLL ? DLL - DLL . void , , # ( " " ..) , ... ++ #.