Question : Forcing 32-bit VB.NET mode on 64-bit machine

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?
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
In VB.NET:
 _
Public Shared Function WebCamInitialize() As Integer
End Function

'This generates the error:
If NativeMethods.WebCamInitialize() <> 0 Then


In C++:
__declspec(dllexport) DWORD APIENTRY Initialize()
{
	HRESULT hr = S_OK;
	// Nothing to really do yet
	return hr;
}

Answer : Forcing 32-bit VB.NET mode on 64-bit machine

Go to Tools -> Options... -> Projects and Solutions -> General -> enable Show advanced build configurations

Go to Build -> Configuration Manager

Create a new solution platform, choose x86.

Make sure the 32-bit DLL is in C:\WINDOWS\SysWOW64 or in the same folder as your VB.Net binary.
 
 
 
 
 
 
 
 
Random Solutions  
 
programming4us programming4us