# .NET and More > WPF, WCF, WF >  The 'Microsoft.ACE.OLEDB.12.0' provider is not registered...' when I test my service

## FunkyDexter

Hi Guys

I've got a WCF library that I'm testing.  One of the services reads data from an excel file using an OLEDB connection.  The connection string reads:-
Provider=Microsoft.ACE.OLEDB.12.0;Data Source=TestData\iris_data.xlsx;Extended Properties="Excel 8.0;HDR=YES"

I've got two sets of tests. One which calls the underlying implementation of the service and one which calls the service layer.  The service layer is just pass-throughs which call the underlying implementation.  There's no intelligence in the service layer at all.

The test that calls the underlying implementation direct is working fine.  It reads the data and does it's work.  However, when I call it via the service layer I'm getting an error message that "The 'Microsoft.ACE.OLEDB.12.0 provider is not registered on the local machine".  I'd have thought I'd get the same result in both places but obviously not.

My best guess at what is happening is that the driver _is_ registered on the local machine (as in the physical box that's sat on the desk in front of me) because otherwise the first test would fail.  However, whencalling the service, VS sets up a virtual web server to host the service and it's that virtual machine that doesn't have the driver on it.

So my question is: Assuming I'm correct, how do I tell the virtual machine to load up and register the driver?  If my assumptions aren't correct can anyone suggest what else may be going on?

Thanks in advance.

----------


## si_the_geek

Historically ACE has only been available as either 32 bit or 64 bit (and you couldn't have both on the same machine), but I think that may have changed in a recent version... I would however recommend checking that both methods are running using the same amount of bits.

----------


## FunkyDexter

Hi Si

Thanks for the response.

How would I check which version of Ace is installed/running?  I had a google but I'm just gettoing loads of hits  with people complaining that you can't have both versions of the drivers installed so my search is getting lost in the morass. I checked in access and that says it's running 32 bit but I'm not sure that would necessarily indicate the ACE driver version.

Off the back of the various articles I read around the above search I did try targetting 86 and 64 bit specifically.  If I set the WCF service project to X64 or X86 and leave the test project as Any CPU I still get the same problem.  If I set the WCF test project and the service project to X64 or X86 it fails to load saying it's a bad image format.

----------


## si_the_geek

I'm not sure how you would check ACE... I would assume that there is something in Control Panel -> Programs, but I haven't got it installed at the moment so can't be sure.

A possible alternative is to create an empty text file and change the extension to .udl , then double-click on it to get an OLEDB connection string builder (which lists the installed providers).


However, based on the info in your latest post it sounds like that might not be the issue.  Another quick check you can do is to ensure that the "Data Source" value has a full path (I doubt it will help, but I have occasionally seen that kind of thing cause this type of error).

----------


## FunkyDexter

Hi Si and thanks for the suggestions.  Sadly none of them got me there.

I can't see anything obvious under programs but I'm not sure what I'd be looking for.  There's nothing that looks like "ACE".

Looking at the provider's in the udl I can see Various Microsoft OLE DB Providers for "X" along with a Microsoft OLE DB Simple Provider and a couple of SQL Server Native Clients (10.0 and 11.0).  None of them mention a version number though, which si what I guess I should be looking at.

The datasource value had a relative rather than a full path for the excel file because I want it to get copied around in the tests.  I tried copying it straight onto a hard path and giving it a full path but it made no difference.

The thing I'm really stumped on is that it seems to be complaining about the driver and I would expect that to be the same on the local machine and in WcfSvcHost since the latter is built form the former.  I don't understand why, then, I would get different behaviour when callin a dll as a project reference to callint it as a service reference.  My understanding of that area is hazy at best though so I could just be missing the point.

----------

