Okay, this one is really puzzling me, and I apologize if the title of the question doesn't accurately describe what my problem is.
I have a program made in C#, using Entity Framework and SQL Server CE. I developed it on Windows 7, and it works fine. I also have a Windows 8.1 machine that I've tested it on, and it works fine on that too.
However, on a few Windows 8.1 computers, the program crashes as soon as it tries to access the database. I get the following error:
Unhandled Exception: System.InvalidOperationException: No Entity Framework provider found for the ADO.NET provider with invariant name 'System.Data.SqlServerCe.3.5'. Make sure the provider is registered in the 'entityFramework' section of the application config file. See http://go.microsoft.com/fwlink/?LinkId=260882 for more information.
Now, this really confuses me, because I have the latest NuGet package for SQL Server CE installed on my project (4.0). I used the SQL Server CE toolbox to explicitly create a SQL Server CE 4.0 database, I distributed the 4.0 dll's with the application, and I explicitly have version 4.0 listed in my app.config
file (invariantName="System.Data.SqlServerCe.4.0"
).
So, why does the error say System.Data.SqlServerCe.3.5
? Why does this error only occur on a couple of Windows 8.1 machines?
(I also searched through my entire solution, and the text "3.5" doesn't even appear anywhere.)
I found similar errors, and I tried (from this question) to include this:
private volatile Type _dependency;
public MyClass()
{
_dependency = typeof(System.Data.Entity.SqlServer.SqlProviderServices);
}
Has no effect, I still get the same exact answer.
Anyways, if anybody has any ideas, I would greatly appreciate any kind of input.