开发者

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.

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


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.


You can always use MSBuild. It is free and will allow you any configuration option available to the complier.


This tutorial works on Visual Basic 2008 Express Edition, but I think it should work on other express editions as well.

The Advanced Compile Options isn't enabled at default in the express edition, to enable it, take the following steps:

Click on 'Tools' Select 'Options' Under 'Projects and Solutions', click on 'General' Then tick the option 'Show advanced build configurations' Click Ok. Voila!!!

You should see changing to any cpu in advanced compile options when you go to Project - Properties.

If not still enabled, go to Build - Configuration Manager and add x86 to platform.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜