Windows 7 : C# Error:'Microsoft.Jet.OLEDB.4.0' provider is not registered on the local machine


Today I have faced this error when try to use MS Access database from SMS software. After goggling I have found the solution in ...
MSDN forum


The behavior you described is expected. If your application runs in 64-bit mode, all of the components it uses must also be 64-bit. There is no 64-bit Jet OLE DB Provider, so you get the message described. You would receive a similar error when trying to connect to a database using OLE DB or ODBC if there is no 64-bit version of the specified OLE DB provider or ODBC driver.
This problem only occurs in applications that run in 64-bit mode. Compiling the application so it runs only in 32-bit mode is the best current solution.

How to compile application to run in both 32 bit or 64 bit?
You can do it several ways...

Solution :1

You can edit your visual studio c# project file (.csproj) and put this snippet:
2.<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">

Solution :2
Using CorFlags to set the 32BIT flag on the executable. E.g:
corflags.exe myapp.exe /32BIT+

This will modify your exe, so you might wanna keep a backup just in case. You can also revert the flag using /32BIT- instead of /32BIT+.

Solution :3(Simplest way)
1.Right click your Project, and select Properties.
2.In properties, select the Build tab. Under Platform target, select x86.
3.Hit Ctrl+Shift+S to save all files, right click the Solution and select "Clean" to get rid of old binaries. Any builds after that should be 32 bit .
Now it is ready for both 32 bit and 64 bit OS.

This should solve the problem ! Please inform me if there is another better way.


Popular posts from this blog

How can I get a value of a property from an anonymous type (C#)

The model backing the 'MyDBContext' context has changed since the database was created. Either manually delete/update the database, or call Database.SetInitializer with an IDatabaseInitializer instance. For example, the DropCreateDatabaseIfModelChanges strategy will automatically delete and recreate the database, and optionally seed it with new data.

"This request has been blocked because sensitive information could be disclosed to third party web sites when this is used in a GET request. To allow GET requests, set JsonRequestBehavior to AllowGet."