- Posted by azazeal on December 3, 2008
- Kick it! |
Having Sql Server Compact 3.5 SP1 embedded in your application for both x32 and x64 systems is really easy and a life saver. I took some screenshots that will guide you through the whole process. Enjoy.
step 0: creating the X86 and AMD64 folders
When your application tries to access Sql Server Compact it first looks whether its dlls exist into the application's directory into 2 specific folders: the X86 and AMD64 folder (for x32 and x64 versions respectively). So, create those 2 folders first.
If your system is x64 and inside the AMD64 folder you've placed the Sql Server Compact dlls then your application will choose that directory by default for you (an easy performance gain).

step 1: adding Sql server compact's dlls to your application
All of the Sql Server Compact Edition components that your application *may* use are defined in 7 dlls that can be found into the Sql Server Compact installation on your development machine (perhaps you can narrow it down to 3-4 dlls depending on what exactly you need from SqlCe but for this example I'll add them all).
In my machine I've installed both the x32 and x64 versions of Sql Server Compact 3.5 so I have all the dlls I need for both platforms.
Bellow can see some screenshots I took while adding the x64 dlls to my project.


The dlls I selected correspond to the x64 version of Sql Server Compact. For the x32 dlls you have to look in the x32 program files folder.
After adding the dlls to your project it's important to select them again and set the "Build Action" to "Content" and the "Copy to Output" property to "Copy always" or "Copy if newer" so that these files are indeed copied to the application directory.

Repeat the above steps but this time place the dlls into the X86 folder and get them from the x32 installation directory of Sql Server Compact.
Last but not least, we have to add the first (and only) reference to our project for System.Data.SqlServerCe and set its "Copy Local" property to "True".

That's it. The last screenshot is what the complete project looks like (with all the references).

Last minute note: If you are using ClickOnce, remember to remove the pre-requisite for Sql Server Compact before you deploy, if you leave that single checkbox checked you defeat the purpose of having Sql Server Compact embedded to your app.
Keep coding and If I don't post anything more till the new year:
"May 2009 be what 2008 wasn't"