Symptoms

On 64-bit computers, a SQL Server Compact (“Compact”) based application may fail with one of the following two symptoms:Symptom 1The application is trying to load a version of Compact that is incompatible with the version that is installed on the computer. Incorrect versions could lead to application instability and the loading of Compact would be aborted. Symptom 2The application cannot load the native components of SQL Server Compact that corresponds to the ADO.NET provider.The following are the exact exceptions that are associated with these issues:

Version Mismatch ExceptionFile version mismatch detected between ADO.NET Provider and native binaries of SQL Server Compact which could result in an incorrect functionality. This could be due to the presence of multiple instances of SQL Server Compact of different versions. Please install SQL Server Compact binaries of matching version [ADO.NET Provider File Version = XXXX, Native Binary File Version = YYYY]Unable to load ME dll Exception”Unable to load DLL 'sqlceme35.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)

Cause

Compact based applications generally program against the Compact ADO.NET provider (System.Data.SqlServerCe.dll). This provider in-turn communicates with the native Compact components. In order to avoid various inconsistencies, a Compact ADO.NET provider of a certain version can talk only to the Compact native components of the same version. The following are some sample scenarios where this policy will be broken, and that will result in one of the previously mentioned two exceptions:

Example Scenario 1

Install SQL Server 2008 R2 (this installs the 32-bit version of SQL Server Compact 3.5 SP2).Then, when you run a 64-bit application privately deploying SQL Server Compact SP1, It fails with the “Version Mismatch" exception.

Reason for the failure

  • When the 32-bit version of the SQL Server Compact 3.5 SP2 is installed, it adds the ADO.NET provider (System.Data.SqlServerCe.dll) of version 3.5.8080 to the Global Assembly Cache (GAC) and the native x86 components are put under the %Program Files(x86)% folder.

  • When the 64bit application that privately deploys SQL Server Compact SP1 is run, the ADO.NET Provider is loaded from GAC (version 3.5.8080) but native 64bit components are loaded from the application folder which is version 3.5.5692.0.

  • There is a version mismatch which is not enabled as per the policy.

Example Scenario 2

  • You install the x86 version of SQL Server Compact 3.5 SP1 on a 64-bit computer.

  • Then, you install the x64 version of SQL Server Compact 3.5 SP1.

  • On the same computer, you download and install the 32-bit version of SQL Server Compact 3.5 SP2 from the Web.

  • You run a 64-bit application that uses SQL Server Compact SP1 or SP2.

  • When you run the application, it fails with the “Unable to load ME dll " exception.

Reason for failure

  1. Installing the 32-bit version of SQL Server Compact 3.5 SP2 upgrades SQL Server Compact 3.5 SP1 x86 installations to SQL Server Compact 3.5 SP2. It results in the x86 installation of Compact being different from the x64 installation.

  2. When a 64-bit application that uses Compact SP1 or SP2 is running on the computer, it loads the ADO.NET Provider from the GAC (version 3.5.8080). However, it cannot find native binaries of the same version on the system. Therefore, it throws the exception.

Resolution

At any given point of time, the correct state of a 64-bit computer, for SQL Server Compact, would be the following:

  • Both x86 and amd64 MSIs are installed.

  • Both x86 and amd64 MSIs are of the same version.

Therefore, if you face any similar issues, make sure that the computer has both x86 and amd64 MSIs of Compact are installed and they are of the same version. In case, they are not, then install Compact SP2 x86 and x64 MSIs from following link as needed:

http://www.microsoft.com/download/details.aspx?familyid=E497988A-C93A-404C-B161-3A0B323DCE24&displaylang=en

Status

Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.

Need more help?

Want more options?

Explore subscription benefits, browse training courses, learn how to secure your device, and more.

Communities help you ask and answer questions, give feedback, and hear from experts with rich knowledge.