Click here to Skip to main content
15,891,033 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more: , +
I am Developing Windows Forms Application using .NET Framework 3.5, VS2012 on Windows 8 (64-bit machine) although I am developing for AnyCPU. The database I use is SQL Server Compact Edition v4.0 and I am getting following error while trying to open a Form in Design mode and VS2012 crashes.

"Unable to load the native components of SQL Server Compact corresponding to the ADO.NET provider of version 8876. Install the correct version of SQL Server Compact. Refer to KB article 974247 for more details."

I tried various combinations but not sure what's going wrong.

1) Tried to reference DLL (System.Data.SqlServerCe.dll) from the following paths:
C:\Program Files\Microsoft SQL Server Compact Edition\v4.0\Private\System.Data.SqlServerCe.dll

C:\Program Files (x86)\Microsoft SQL Server Compact Edition\v4.0\Private\System.Data.SqlServerCe.dll

2) Tried to copy supporting DLLs from the following path to Bin\Debug path
C:\Program Files\Microsoft SQL Server Compact Edition\v4.0\Private\amd64
C:\Program Files\Microsoft SQL Server Compact Edition\v4.0\Private\x86

Can anyone help here?

Thanks,
CB
Posted
Updated 27-Jun-13 18:21pm
v3

Make sure the AMD64 and x86 folders (and files and sub folders)are in your output folder for debugging. Either include them in the project with copy local, or manually copy and paste them into your bin/debug file.
 
Share this answer
 
You need to add the following:

SqlCeConnection conn = new SqlCeConnection("Data Source=nonExistingSource.sdf;");

try
{
conn.Open();
}
catch (SqlCeException e)
{
// Use SqlCeException properties if you need specific
// application logic depending on the error condition
//
if (25046 == e.NativeError /*SSCE_M_FILENOTFOUND*/)
{
// Error specific logic goes here...
//
}

MessageBox.Show(e.Message);
}
 
Share this answer
 
Do you have SQL Server Compact Edition 4[^] installed in your machine? Try installing that. This problem occurs because the compiler is unable to load required assemblies. You don't need to remove earlier version of SQL Server Compact edition.

I am not sure but may be one more checkpoint is there. See a similar thread here[^].


--Amit
 
Share this answer
 
Comments
[no name] 28-Jun-13 10:41am    
Yes, I have SQL CE 4.0 installed. I have no issues on runtime or compile time. My application builds successfully. But Design Mode, VS2012 crashes as soon as I try to open the Form. Why Visual Studio runs the code (Form_Load event) during design mode? Can we disable running code in Design mode?
RedDk 28-Jun-13 13:21pm    
Disable running code: add a debug stop in the debug mode browse while under test (run).
Yes, this was resolved with the same techniques. I had included both folders x86 and amd64 in my project root folder with all related dlls inside it. Sorry for not updating this earlier.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900