views:

82

answers:

2

I am trying to use Microsoft.Jet.OLEDB driver to connect to an access database from my C# application. When I try to open a connection, I get an error: "The 'Microsoft.Jet.OLEDB.4.0' provider is not registered on the local machine." This is because the driver is only supported on 32 bit machines.

My solution was to change the platform target of the project that references it to x86. If I try to change all of my projects to x86 I get major build problems, so I am leaving them all on 'Any CPU'

Problem now is when I start up in VS, it tells me: "Could not load file or assembly 'MyProject, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format."

I've tried about every configuration I can think of and I just can't quite get it to work. Any tips?

+4  A: 

You'll have to switch the whole thing to x86. As you've found, there isn't an x64 driver for Access.

Your other code, if compiled x64, can't use x86 assemblies. You might want to review this question: http://stackoverflow.com/questions/2698830/can-an-x64-application-use-x86-assemblies-and-vice-versa

UPDATE

Interestingly, I found the Access Database Engine x64 from MS. You might try to grab that and see if it will work for you. You might also check out this discussion on MSDN.

Chris Lively
I was worried about that. Its gonna be a pain to make it all run in x86.
CaptnCraig
+2  A: 

You do have to switch to 32-bit to use Jet. (Edit: unless you use the new driver a couple of other posters have referenced).

If any one of your projects is using image lists, there is a bug that will cause errors when switching from 64-bit to 32-bit. As I recall you either have to rebuild the image lists from scratch or drop them and use something else instead.

You can find more info here and here.

Jon B