Search code examples
databasevb.netms-access32-bit

Compiling a .NET application as 32-bit only so I can use my Access database


I keep getting this error when I try and use an MS Access database in my application:

The 'Microsoft.Jet.OLEDB.4.0' provider is not registered on the local machine.

After Google'ing the error for a while I came to see that this is a problem when running the application in 64-bit mode. If I was to compile the application in 32-bit it would work, so I went to try and find out how to do it. I got as far as the advanced compiling options in my projects settings page, but then I also read that I can't even set the CPU type in Visual Basic 2008 Express.

Is this true? Is there no way I can set my project to run in 32-bit mode? The thing is, I did a similar thing with a database a few months ago and this worked, and I don't remember in the slightest what I did.

How do I fix this problem?

After taking a look at my old projects compiling options, it is indeed set for Active (x86) Platform, but this option is not showing up in my new project. Weird.

Here's a screenshot. The top one is the old project with the 32-bit running option and the bottom is the new one without those options.

Enter image description here


Solution

  • I haven't used VB Express myself (I use Visual Studio Professional) but I figure the options will be similar. After you open the solution (or project):

    1. Open the Project Properties. (Right click the Project in the solution explorer and select properties).
    2. Click on the Build tab.
    3. In the Platform Target drop down, select x86.
    4. Click Save.

    You should now be able to build the application and force it to 32-bit.

    If you wish to have separate builds (one for Any CPU and one for x86):

    1. Click on the Build menu.
    2. Click Configuration Manager...
    3. In the Active Solution platorm drop down click
    4. In the Type or select the new platform drop down select x86.
    5. Make sure Create new project platforms is checked.
    6. Click OK.

    You can now choose between the Any CPU or x86 CPU types easily. Just select the platform type from the Standard toolbar.

    If you need to change an older program or one you can't compile, see my answer on how to force applications with the Any CPU flag to run as 32-bit.