Using my 64-bit machine, I have compiled a Win32 DLL using Visual C++ 2008 Express. When I try to call a routine from this DLL using VB.NET 2008 Express, I get the error message "An attempt was made to load a program with an incorrect format". Following advice elsewhere, I used Notepad to change all Platform configurations to "x86" (were previously "Any CPU") in my VB.NET project files. However, the error message still remains. The problem is not that the DLL is in the wrong place; when I rename it, VB.NET throws a different error saying it can't find the DLL. What can I do to get VB.NET 2008 Express to properly execute my DLL on my 64-bit machine?
<DllImport("WebCamLib.dll", EntryPoint:="Initialize")> _
Public Shared Function WebCamInitialize() As Integer
'This generates the error:
If NativeMethods.WebCamInitialize() <> 0 Then
__declspec(dllexport) DWORD APIENTRY Initialize()
HRESULT hr = S_OK;
// Nothing to really do yet