Application can't find SQL CE after prerequisite GAC install of SQL Server Compact 3.5 SP1
-
Friday, May 04, 2012 5:50 PM
I developed a Windows forms application in Visual Studio 2010 which uses SQL Server Compact 3.5 SP1. It runs fine in the IDE on my development computer and I am building an installer so the application can be deployed to other computers where Visual Studio is not installed.
In testing my installer, I created a Windows XP SP3 virtual machine in Virtualbox under Windows 7 Ulitmate (x64) and I am having some kind of problem which may be related to the prerequisite install of SQL Server Compact 3.5 SP1 to GAC. The install seems to be successful, SQL CE 3.5 SP1 appears installed in the Control Panel under Add/Remove Programs, but when the application is executed I get the following error:
- The type initializer for 'cds.cds_common' threw an exception. System.IO.FileNotFoundException: Could not load file or assembly 'System.Data.SqlServerCe, Version=3.5.1.0, Culture=neutral... The system cannot find the file specified
I tried copying the 7 SQL CE DLLs (plus 'System.Data.SqlServerCe.dll') into the ApplicationDirectory, after which execution of the application throws a series of different exceptions:
- The application or dll ... "sqlceme35.dll" ... is not a valid windows image. (This error message is paraphrased, and it occurs in sequence for several of the SQL CE DLLs)
Can anyone suggest what I may be doing wrong in my installation of SQL CE on the target computer? I thought that since I was installing to GAC via the Windows installer, SQL CE would be accessible to all users. Should I use a private deployment instead, and how do I do this in an installer when the host CPU type may be x86 or x64?
Thanks for any help.
-BGood
All Replies
-
Saturday, May 05, 2012 6:07 PMModerator
Private deployment with 3.5 SP2 is a good approach, and supports both x64 and x86 in a single package. See my blog post here for step by step instructions: http://erikej.blogspot.com/2011/02/using-sql-server-compact-40-with.htmlPlease mark as answer, if this was it. Visit my SQL Server Compact blog
- Marked As Answer by Maggie LuoMicrosoft Contingent Staff, Moderator Thursday, June 07, 2012 7:37 AM
-
Saturday, May 05, 2012 7:17 PMThanks, Erik. I'll give private deployment a try.
-BGood
-
Monday, May 14, 2012 10:09 PM
Hi ErkiEJ,
When I tried deploying using a full GAC installer, SQL CE was not found so I tried your private deployment suggestion and am getting the following error:
"An attempt was made to load a program with an incorrect format.... The application or DLL C:Program Files\........\sqlceme35.dll is not a valid windows image. Please check this against your installation diskette."
My installer software was made with Advanced Installer from a VS2010 VB project targeting .NET 4.0. The SQL CE 3.5 SP2 dlls were copied from the 3.5 and Private folders of my Win 7 x64 development computer. I am attempting to install to a Windows XP SP3 virtual machine on the same computer under Virtual Box.
Any suggestions? Thanks.
-BGood
-
Tuesday, May 15, 2012 6:52 AMModeratorDid you follow my blog instructions? the x64 binaries in a folder called AMD64, the x86 binaries in a folder call x86 ?
Please mark as answer, if this was it. Visit my SQL Server Compact blog
-
Tuesday, May 15, 2012 2:35 PM
ErikEJ, thanks for the quick response.
I read your blog, but could only partially follow your instructions because on my development machine, there were not separate installation folders for amd64 and x86. My development machine is an AMD64 and there are separate Sql Server Compact directories in both Program Files and Program Files x86.
Two possible issues may be:
- I also do not understand what the YES and NO entries signify in your matrix.
- I also notice that I did not include a Visual C++ 2005 Redistributable in my installation package.
Thanks for your help. I have been using SQL Server Compact for several years in the development environment, but this is my first attempt at deployment. Sorry for the dumb questions.
-BGood
-
Tuesday, May 15, 2012 5:10 PMModerator
I do not see a Matrix in the referenced blog post.
For 3.5, pick up the amd64 dll files in c:\program files and the files for the x86 folder fro c:\program files (x86) (!!!)
If .NET is installed, the VC++ runtime files are present, dont worry about that.
Please mark as answer, if this was it. Visit my SQL Server Compact blog
-
Tuesday, May 15, 2012 5:44 PM
ErikEJ,
In reading through your SQL CE Blog, the matrix I was asking about is located here:
http://erikej.blogspot.com/2010/11/sql-server-compact-private-deployment.html
On my development machine, it seems that SQL Server Compact 3.5 SP1 was automatically updated to SP2, maybe in conjunction with VS2010 SP1 when I was trying to solve the object nesting bug in the Reportviewer (I never could resolve this, but that's another story).
From the compatibility matrix referenced above, would there be any advantage in deploying SQL server Compact 3.5 SP1 instead of SP2?
My application requires .NET 4.0 (full) and I would prefer not deploying .NET 3.5 if it is not necessary.
Many thanks for your help.
-BGood
-
Tuesday, May 15, 2012 6:52 PMModerator
No, use 3.5 SP2.
This is what it means:
If your clients are all Win7, then you do not have any issue, as this platform includes the required VC++ binaries (with .NET 3.5 SP1), but if your client are older platforms, then either .NET 3.5 SP1 or at least the VC++ runtime redist must be installed.
If you use SQL CE 4.0 with .NET 4.0, just follow my MSI blog post, and all components are there.
Please mark as answer, if this was it. Visit my SQL Server Compact blog
-
Tuesday, May 15, 2012 7:26 PM
ErikEJ,
Thanks for the suggestion regarding CE 4.0, but my application uses Linq to SQL and because of this I cannot use CE 4.0.
I am still working on developing the best SQL CE 3.5 installation strategy. As many potential customers will still have Windows XP, my initial installation tests are on a Windows XP SP3 virtual machine. I don't fully understand why my application does not run after a full GAC install of SQL CE 3.5 SP1 in this environment, but looking at your SQL Server Compact 3.5 SP2 matrix, I see that both .NET and 3.5 and 4.0 may be required in this environment. I'll give that a try.
-BGood
-
Wednesday, May 16, 2012 6:59 AMModerator
yes, .NET 3.5 SP1 (or the Visual C++ runtime) is required by SQL Server Compact, and .NET 4.0 is required by your app.
LINQ to SQL can work with 4.0 - see http://erikej.blogspot.com/2012/04/using-linq-to-sql-with-sql-server.html
Please mark as answer, if this was it. Visit my SQL Server Compact blog
- Marked As Answer by Maggie LuoMicrosoft Contingent Staff, Moderator Thursday, June 07, 2012 7:37 AM

