🚀 Welcome to MDriven Learn –  MDriven is now on Discord!  Don’t miss the latest Release Notes.
Possible file version mismatch detected between ADO.NET Provider and native binaries of SQL Server Compact
This page was created by Hans.karlsen on 2020-05-01. Last edited by Wikiadmin on 2026-07-29.

You can resolve this SQL Server Compact startup or runtime error when deploying an MDriven application that cannot load matching SQL Server Compact provider and native binaries.

What the error means

The message Possible file version mismatch detected between ADO.NET Provider and native binaries of SQL Server Compact means that the managed SQL Server Compact ADO.NET provider does not match the native SQL Server Compact binaries available to the application.

A deployment can contain multiple SQL Server Compact versions, or it can contain binaries with the expected file names but from a different version. The application may then load a provider from one location and a native binary from another. This can cause incorrect behavior or prevent the application from running.

This issue is also common when you build or publish from a 64-bit machine for a 32-bit site. In that case, the published site can be missing the required x86 SQL Server Compact native binaries.

Identify the affected deployment

Before changing the database or rebuilding the model, confirm that this is a binary deployment issue.

  1. Read the complete error message and determine whether it names SQL Server Compact.
  2. Check whether the failing site is deployed as a 32-bit site.
  3. Compare the SQL Server Compact files in the published site with the files used by the build that produced the deployment.
  4. Check for duplicate SQL Server Compact binaries in the deployment or in locations from which the application can load assemblies.
  5. Republish after correcting the files, then restart the application and test the operation that previously failed.

For example, if a site was published on a 64-bit development machine but runs as a 32-bit site, verify that the published output contains the x86 SQL Server Compact native binaries. Publishing only the 64-bit binaries does not satisfy a 32-bit site.

Correct the SQL Server Compact binaries

Deploy matching versions of the SQL Server Compact ADO.NET provider and its native binaries. Do not combine files from separate SQL Server Compact installations or releases.

Check for mixed or duplicate files

Multiple SQL Server Compact installations can leave different versions of similarly named files on the machine or in deployment output. A wrong binary with the same name can be loaded instead of the binary intended for the application.

Use this checklist:

  • Remove outdated or unintended SQL Server Compact files from the published site.
  • Ensure that the provider and native binaries copied into the deployment are from the same SQL Server Compact version.
  • For a 32-bit site, ensure that x86 native binaries are included in the published output.
  • Republish the complete set of matching SQL Server Compact files rather than manually replacing one file.
  • Restart the site after deployment so it does not continue to use files loaded before the update.

Ensure SQL Server Compact files are published

In modern distributions, configure the SQL Server Compact DLLs to use Copy Always rather than Copy if newer (also described as CopyWhenNewer). This makes the publish process copy the intended binaries even when timestamps or existing files would otherwise prevent replacement.

For example, if an older native binary remains on the target server and the publish process considers it current enough to keep, using Copy Always replaces it with the binary that matches the deployed provider.

After changing the copy behavior:

  1. Clean the deployment output so old SQL Server Compact files are not retained.
  2. Build and publish the application again.
  3. Verify that the x86 binaries are present when the target is a 32-bit site.
  4. Restart the application and retest.

Do not confuse this with database corruption

This error concerns the SQL Server Compact runtime files, not necessarily the contents of the database. Do not modify or replace DatabaseCompact.sdf as the first response to a provider/native-binary mismatch.

If MDrivenServer's built-in database does not evolve correctly between deployments, investigate the separate corruption scenario in Documentation:Corrupt MDriven Server. To inspect a downloaded DatabaseCompact.sdf file, use the guidance in Documentation:MDrivenServer, opening the built-in database.

Related deployment problems

The following errors can appear after a deployment but have different causes:

Symptom Likely scope What to do
SQL Server Compact provider and native binary version mismatch SQL Server Compact files are missing, mixed, or wrong for the site architecture. Deploy matching provider and native binaries; include x86 binaries for a 32-bit site; use Copy Always for the SQL Server Compact DLLs.
Failure while saving an ECO model database script SQL Server Compact installation required by the development environment may be missing. See Documentation:Problem saving database script.
CodeFoundButOutOfSync Deployed CodeDress assemblies and referenced DLLs have different versions. See Documentation:CodeFoundButOutOfSync.
MDrivenServer fails to evolve its built-in database The built-in database or its mapping may be corrupt. See Documentation:MDriven Server problem with evolve and Documentation:Corrupt MDriven Server.

If you are debugging a Turnkey installation locally, also make sure that the installed Turnkey version and the framework version used by Visual Studio agree. Framework and .NET Core binaries are different; a CodeDress built for one does not work with the other. See HowTos:Debug Turnkey Generic Code.

See also