Troubleshooting: Privately deploying the SQL Server Compact 3.5 SP2 ADO.NET Entity Framework provider (System.Data.SqlServerCe.Entity.dll) in the application folder does not work

For complete instructions about deploying SQL Server Compact ADO.NET Entity Framework provider (System.Data.SqlServerCe.Entity.dll) privately in the application’s folder refer to the blog here. Note that from SQL Server Compact 3.5 SP2 release onwards if you are privately deploying SQL Server Compact 3.5 SP2 DLLs in your application folder you need to copy the managed DLLs (System.Data.SqlServerCe.dll and System.Data.SqlServerCe.Entity.dll) from the location %Program Files%\Microsoft SQL Server Compact Edition\v3.5\Private. Refer to the SQL Server Compact 3.5 SP2 Books Online for more information.


When an application uses System.Data.SqlServerCe.Entity.dll from SQL Server Compact 3.5SP2 in xcopy (i.e. private) deployment mode by copying the Compact’s ADO.NET provider (System.Data.SqlServerCe.dll) and the Compact’s ADO.NET EF provider (System.Data.SqlServerCe.Entity.dll) DLLs from the %Program Files%\Microsoft SQL Server Compact Edition\v3.5\Private, following exception is thrown:
"System.IO.FileLoadException: Could not load file or assembly 'System.Data.SqlServerCe, Version=, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)"


System.Data.SqlServerCe.Entity.dll and System.Data.SqlServerCe.dll from the Private folder is of version But unfortunately, the System.Data.SqlServerCe.Entity.dll from the Private folder (i.e. with version is referring to System.Data.SqlServerCe.dll from the Desktop folder (i.e. with version Due to this, an application that has only the dlls from Private folder fails as it doesn't find the version of System.Data.SqlServerCe.dll.


Add assembly binding redirection entry in app.config file.
Append following lines under the configuration section of the app.config:

<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<assemblyIdentity name="System.Data.SqlServerCe" publicKeyToken="89845dcd8080cc91" culture="neutral"/>
<bindingRedirect oldVersion="" newVersion=""/>

- Vipul Hattiwale