Tuesday, May 15, 2012

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

Recently, I faced an exception "The 'Microsoft.Jet.OLEDB.4.0' provider is not registered on the local machine." when trying to read an excel file from my .net web application. It is working fine on my development machine but after I deployed it to the production server, it hits the error. The cause of the issue is that the web server hosting my application is running in x86 version of Windows and the default compile option of my application is set to run at Any CPU (For vb.net, the compile option can be set in the Project Properties --> Compile --> Advanced Compile Options).

The solution to the problem:
1. Set the Target CPU in the compile option to x86 and rebuild.
2. In web  server IIS, set the application pool of your application to allow 32bit .net application (Select your application pool --> Advanced Settings. Under the General category, change the setting "Enable 32-Bit Application" to True).

Hope it helps =)