views:

1009

answers:

3

Hi - I'm developing a Winforms application using Visual Studio 2008 C# that uses a SQL compact 3.5 database on the client. The client will most likely be 32 bit XP or Vista machines. I'm using a standard Windows Installer project that creates an msi file and setup.exe to install the app on a client machine. I'm new to SQL compact so I haven't had to distribute a client database like this before now. When I run the setup.exe (on new Windows XP 32 bit with SP2 and IE 7) it installs fine but when I run the app I get the error below:

Unable to load DLL 'sqlceme35.dll'. The specified module could not be found

I spent a few hours searching this error already but all I can find are issues relating to installing on 64 bit Windows, none relating to normal 32 bit that I'm using. The install app copies the all the dependant files that it found into the specified install directory, including the System.Data.SqlServerCe.dll file (assembly version 3.5.1.0). The database file is in a directory called 'data' off the application directory, and the connection string for it is

<add name="Tickets.ieOutlet.Properties.Settings.TicketsLocalConnectionString"         connectionString="Data Source=|DataDirectory|\data\TicketsLocal.sdf"  providerName="Microsoft.SqlServerCe.Client.3.5" />

Some questions I have:

  • should the app be able to find the dll if it's in the same directory i.e. local to the app, or do I need to install it in the GAC? (If so cam I use the Windows Installer to install a dll in the GAC?)
  • is there anything else I need to distribute with the app in order to use a Sql Compact database?
  • there are other dlls also such as MS interop for exporting data to Excel on the client. Do these need to be installed in the GAC or will locating them in the application directory suffice?

TIA,

Ciaran.

A: 

This should help, at least with your first two questions: http://msdn.microsoft.com/en-us/library/aa983326(VS.80).aspx

In general, I think you should not install anything in the GAC for a single application.

JimG
A: 

You don't need it to be in the GAC for sql compact to run and it will pick them up from the application directory. There are several ways to deploy a sqlcompact project the two main ways are:

  1. Deploying the sqlCompact redist. installer with your project, but this way is a pain in the ass and also can be unistalled by the end user, or upgraded by windows updates and breaking your app.

  2. Including the .dlls in your application folder. Depending on the features of sqlcompact you are using (replication or whatever) there a handful of .dll's to deploy in your application folder.

IF you have sql compact installed on your machine they are most likely located at "C:\Program Files\Microsoft SQL Server Compact Edition\v3.5". They can be added to the project in visual studio and then set their project output type to "copy always". And the main reference to System.Data.SqlServerCe that you have in your project references should have copy local set to true.

sqlceca35.dll sqlcecompact35.dll sqlceer35en.dll sqlceoledb35.dll sqlceqp35.dll sqlcese35.dll

If you have these all set then in your installer project all you have to include is the project output of this project and you're good. In my opinion this is the only way to go, It is a simple deployment, of a couple files and you are in control of what dll versions you app uses.

Hope that helps.

sadboy
Hi thanks for that. After the 1st replies above I spent a couple of day looking at ClickOnce, but I am now back to an MSI solution as ClickOnce doesn't work very well when distributing a compact database with an app. I didn't solve the original problem I had but I'll try including the .dlls. I did have the sqlceme35.dll in the app directory the first time but I still got the error, so not sure if the error will still be there.
Ciaran Bruen
Yeah, hope it works. We have an enterprise level smart client app deployed via click once and with an embedded sql compact database with thousands of end users, and so far this solution seemed to work the best for us as far as easy deployment and automatic updates of the app.
sadboy
Actually it just rang a bell (or I should say it clicked once you said that... ohhh), i didn't realize you were deploying via click once. Also check in your click once project settings if you click on the publish tab/Application Files and then include the sql dll's they will get deployed properly, you might have to check show all to see them.
sadboy
Well after the original MSI attempt I switched to ClickOnce. The problem I had with that was when a new version of the app is available and gets downloaded, the whole app is set up in a new directory structure. This means the SQL compact database that I had in the original app folder isn't visible to the new app. I could have copied the database to a different folder, and check each time the app runs if it exists, if not copy it etc etc, but it seems very clunky. Where did you place the local database in your app...did you store it in the LocalApplicationData or somewhere else? Cheers, C
Ciaran Bruen
We went with Application.UserAppDataPath which is actually different for each version, except it copies the contents from the previous version to allow for click once rollbacks. If you don't set a minimum required version the user can rollback through add remove programs and get to the old version/database. Another good option for click once if you don't want databases building up and being copied to new directories, but want the directory to be the same across versions is Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "YourCompany");
sadboy
Hi got distracted from this but I'm back at the deployment again. Ya I like the idea of the directory being the same across versions..think that would be preferable. When you say "it copies the contents from the previous version", do you mean the click once automatically does this by itself somehow, or do you have to manually set it up to do it?
Ciaran Bruen