I installed SQL Server Compact 3.5 x86 and started testing it out when I got a nice “Unable to load DLL ‘sqlceme35.dll” runtime exception. This seems like odd behaviour for a clean install. In a fairly quick search I found an article on the SQL Server Compact Team Blog that covers a couple possible causes/solutions for this exception.
My Solution - Target x86 Only
Even though there are 5 possible causes/solutions listed, only one of them was the issue I was experiencing and I think is probably the most common issue.
Quoted from the above post:
*If your machine is a 64-bit box, you might have been got trapped into default target platform ‘Any CPU’ trap, please set the target platform as ‘x86’. Need more details, please visit ErikEJ’s blog post. *
To fix it all you need to do is open up the Build Configuration Manager within Visual Studio and change the Active Solution Platform for your application from “Any CPU” to “x86”. Then rebuild and it’ll work just fine.
The reason for this issue according to ErikEJ’s post is “SQL Compact is only supported in 32 bit WoW (Windows on Windows) mode on the x64 platform.” From my understanding of how things work, when you compile for “Any CPU” your application will be run under the 64-bit .NET Framework on x64 Windows, and since SQL Compact is only 32-bit then Windows is unable to fire it up within the same process. This is because a single process in Windows can be either 32-bit or 64-bit and cannot run both 32-bit and 64-bit code within the same process. This is why it runs without throwing the exception once you change your app to target “x86” (32-bit).
What about 64-bit (x64) support?
Since the above SQL Server Compact Team Blog post was written, they have released a x64 version of SQL Server Compact 3.5. So x64 IS supported.
Now, if you distribute your application targeting “Any CPU” and bootstrap the SQL Compact x86 installer within your applications installer you will end up having issues if your users are running a 64-bit edition of Windows. So , to really support x64 Windows you really have two options:
- Change your application to target "x86" and distribute it that way. It'll run on both x86 and x64 editions of Windows.
- Alternatively, you could create two seperate versions of the installer for your application; one that targets x86 and one that targets x64.
I prefer the first option because it has a couple benefits. Even though it only targets x86, it will work on x64 systems too, and you relieve users from being required to understand whether they should install the x86 or x64 version. Plus this way you only need to worry about building your application and installer a single time for each release.
At the below link you can download both the x86 and x64 versions of SQL Server Compact 3.5 SP1:
- 10 Oct 2020
- 01 Jul 2020
- 06 Apr 2020
- 11 Mar 2020
- 15 Feb 2020
Recent on Build5Nines.com
- 04 Dec 2020
Latest Cloud News: Apple on K8s, IoT, Microsoft Pluton and more! (November 20, 2020 Build5Nines Weekly)20 Nov 2020
Latest Cloud News: .NET 5 Released, Apple Silicon M1 CPU, and more! (November 12, 2020 Build5Nines Weekly)12 Nov 2020
- 11 Nov 2020
Latest Cloud News: Kubernetes, Terraform, Teams Multi-Login and more! (November 5, 2020 Build5Nines Weekly)05 Nov 2020
This site is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com. We also participates in affiliate programs with Udemy, and other sites. This site is compensated for referring traffic and business to these companies.