2

I've applied SQLCE in a project I've been working. It works fine in Visual Studio and when I run locally (http://localhost:####) it runs perfectly. But when I publish it at my remote host I receive the "Yellow Screen of Death" the following error message:

Failed to find or load the registered .Net Framework Data Provider.

My Web.Config and references are OK (As I said it work fine at localhost) there is no need to chenge it. The sdf file is deployed in the correct path.

What is missing?

Andre Vianna
  • 1,713
  • 2
  • 15
  • 29
  • Duplicate of http://stackoverflow.com/questions/3223359/cant-get-sql-server-compact-3-5-4-to-work-with-asp-net-mvc-2/3223450#3223450 – ErikEJ Nov 12 '10 at 23:16

2 Answers2

4

I found the answer. When SQLCE is installed to your project it add some files and folders under the bin directory of your webapp.

The following files and folders must be deployed along with you app in the bin folder.

Microsoft.Data.Entity.CTP.dll
System.Data.SqlServerCe.dll
System.Data.SqlServerCe.Entity.dll
WebActivator.dll
[x86] (folder)
[x86]\sqlcecompact40.dll
[x86]\sqlceer40EN.dll
[x86]\sqlceme40.dll
[x86]\sqlceqp40.dll
[x86]\sqlcese40.dll
[amd64] (folder)
[amd64]\sqlcecompact40.dll
[amd64]\sqlceer40EN.dll
[amd64]\sqlceme40.dll
[amd64]\sqlceqp40.dll
[amd64]\sqlcese40.dll

The files in the root of the bin folder (the first four I mentioned above) were deployed but for some reason the x86 and amd64 folders were not sent.

After I deployed those files the app worked fine in the remote host also.

Andre Vianna
  • 1,713
  • 2
  • 15
  • 29
  • 1
    I think you won't need to copy the SQLCE dlls into your bin directory once .Net 4.0 SP1 be released, since they are going to come with standard .Net framework installation. – Morteza Manavi Nov 12 '10 at 21:33
  • I used the Private File–Based Deployment as described here: http://msdn.microsoft.com/en-us/library/aa983326%28v=vs.80%29.aspx – Leniel Maccaferri May 03 '12 at 16:41
  • Easiest solution is to add a post-build step to copy these from the NuGet package NativeBinaries folder. – Dale Anderson Mar 23 '15 at 20:11
1

The problem is because your remote host does not have the provider for SQLCE. If you look at your connection string it is something like this:

<connectionStrings>      
  <add name="name" 
       connectionString="Data Source=|DataDirectory|yourDbFileName.sdf" 
       providerName="System.Data.SqlServerCe.4.0"/>      
</connectionStrings>

Please note that SQL CE and its System.Data.SqlServerCe.4.0 provider has been released after .Net 4.0 so it was not included in standard .Net framework 4.0. So SqlServerCe.4.0 provider is Missing

Morteza Manavi
  • 33,026
  • 6
  • 100
  • 83
  • No. The connection string is correct. See the correct answer I posted. – Andre Vianna Nov 12 '10 at 17:24
  • I did not say your connection string is wrong, I said your remote host does **NOT** have SqlServerCe.4.0 provider installed because it has been released after .Net 4.0. Sometimes it's a good idea to read the answer first before voting it down :) – Morteza Manavi Nov 12 '10 at 17:28
  • They don't need to have SqlServerCe 4.0 installed. The dlls I mentioned above are enough to use the sdf file SQLCE functionality. I think this is the best thing about SQLCE 4.0 I'm not dependent of the host db config an restrictions anymore. – Andre Vianna Nov 12 '10 at 17:37
  • I agree, it's great that it can be configured without any dependency to the host. – Morteza Manavi Nov 12 '10 at 21:31