Tuesday, August 25, 2015

The 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine.

Today, I got struck with a very strange issue, while reading Excel file using OLEDB driver for MS Access, my code worked perfectly on my development system but on posting on live server, I got a very strange error. "The 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine." 


Note: MS Office not installed on the server

I had downloaded the same link:

http://www.microsoft.com/en-us/download/details.aspx?id=13255

http://www.microsoft.com/download/en/confirmation.aspx?id=23734

I found the root cause when I read this blog:

http://stackoverflow.com/questions/15538774/microsoft-ace-oledb-12-0-provider-is-not-registered-but-it-is

I can think of two scenarios that could explain your issue:

Your C# project is set to target both 64-bit and 32-bit platforms and the 64-bit machine has only the 32-bit version of the Access Database Engine installed. The reference fails because the program is running as 64-bit but the machine is missingC:\Program Files\Common Files\Microsoft Shared\OFFICE14\ACEOLEDB.DLLYour C# project is set to target 32-bit platforms only (x86) and the 64-bit machine has only the 64-bit version of the Access Database Engine installed. The reference fails because the program is running as 32-bit but the machine is missingC:\Program Files (x86)\Common Files\microsoft shared\OFFICE14\ACEOLEDB.DLL
Note that the installer for the 64-bit version of the Access Database Engine installs just the 64-bit version, not both.

It made me look into where my driver was installed. My server is 64 bit server and my code expected OLEDB driver(ACEOLEDB.DLL) to be in  C:\Program Files\Common Files\microsoft shared\OFFICE14\ACEOLEDB.DLL, but the dll was actually present in C:\Program Files (x86)\Common Files\microsoft shared\OFFICE14\ACEOLEDB.DLL


Finally found the solution: 

http://www.connectionstrings.com/the-microsoft-ace-oledb-12-0-provider-is-not-registered-on-the-local-machine/


On 64-bit Windows and 64-bit Office (2010, 2013) environments, there are many reports on this error. The fix or workaround is a bit strange but seems to work for most people out there.
The "Microsoft Access Database Engine 2010 Redistributable" installation package seems the natural one to use but several reports says it does not work.
Instead, using the "2007 Office System Driver: Data Connectivity Components" seems to solve the above problem for most people.
And as suggested by many people, the final step was by changing the Visual Studio: Build | Platform Target explicitly to X86. I had it set to Any CPU previously.

No comments:

Post a Comment