SQL Server Compact error: Unable to load DLL 'sqlceme35.dll'. The specified module could not be found - sql-server

I'm developing a Windows Forms application using Visual Studio 2008 C# that uses an SQL Server Compact 3.5 database on the client. The client will most likely be 32 bit Windows XP or Windows Vista machines. I'm using a standard Windows Installer project that creates an MSI file and setup.exe to install the application on a client machine. I'm new to SQL Server 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 Internet Explorer 7) it installs fine, but when I run the application I get this error:
Unable to load DLL 'sqlceme35.dll'. The specified module could not be found
I spent a few hours searching for this error already, but all I could find were issues relating to installing on 64 bit Windows and none relating to normal 32 bit that I'm using.
The install application copies the all the dependent 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 application be able to find the DLL file if it's in the same directory, that is, local to the application, or do I need to install it in the GAC? (If so, can I use the Windows Installer to install a DLL file in the GAC?)
Is there anything else I need to distribute with the application in order to use a SQL Server Compact database?
There are other DLL files 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?

You don't need it to be in the GAC for SQL Server Compact to run, and it will pick them up from the application directory. There are several ways to deploy an SQL Server Compact project. The two main ways are:
Deploying the SQL Server Compact redistributable installer with your project, but this way is painful and also can be unistalled by the end user, or upgraded by Windows updates and breaking your application.
Including the DLL files in your application folder. Depending on the features of SQL Server Compact you are using (replication or whatever), there is a handful of DLL files to deploy in your application folder.
If you have SQL Server 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 of files and you are in control of what DLL versions your application uses.
I hope that helps.

I had a similar problem, a Visual Studio 2008 Windows application targeting 32-bit Windows XP and Windows Vista that used SQL Server Compact 3.5 SP1 - that then got this error when installed on 64-bit Windows 7:
Unable to load DLL 'sqlceme35.dll'. The specified module could not be found
I was embedding an MSI for SQL Server Compact into the installer for the application.
Following this rather confused discussion on MSDN revealed that I needed to use the 64-bit MSI for SQL Server Compact on 64-bit machines. D'oh! That is, from page Microsoft SQL Server Compact 3.5 Service Pack 1 and Synchronization Services for ADO.NET version 1.0 Service Pack 1 for Windows Desktop I needed SSCERuntime-ENU-x64.msi rather than SSCERuntime-ENU-x86.msi for 64-bit machines.

How to: Deploy a SQL Server Compact Edition Database with an Application should help, at least with your first two questions.
In general, I think you should not install anything in the GAC for a single application.

The following provide a solution to the problem and an explanation also.
Troubleshooting: Can’t load SQL Server Compact DLL
SqlCeException on application's first use of SQL Server Compact
Laxmi Narsimha Rao Oruganti 's blog
I hope this helps.

Related

Having trouble migrating from sql 2000 to sql 2008

I have an old 32-bit application sitting on a sql server 2000 personal edition windows NT 6.0 service pack 2.
I am performing a side-by-side migration
I was given a windows 2016 x64.
I installed SQL Server 2008 developer edition x86
I backed-up and restored the necessary databases, changed compatibility level, move logins and permissions, move over necessary extended stored procedures.
ISSUE: The application throws an error when trying to connect. 'Could not load the DLL C:\Program Files (x86)...applicationspecified.dll, or one of the DLLs it references. Reason: 126(The specified module could not be found.)'
I did check to confirm the path is correct.
I used dependency walker to see if there were any missing DLLs
EDIT: The app was installed on the new windows server (2016), opening the app while on windows 2016 against old database/sql2000 works fine. Opening the app against the new databases/sql2008 fails.

Error deploying Microsoft System CLR Types per SQL Server witch ClickOnce

I'm trying to deploy an application that uses Microsoft ReportViewer 2012 that needs Microsoft® System CLR Types per SQL Server 2012 in order to work but I can't get to install it with ClickOnce.
I checked them in project's prerequisites but it seems they cannot be found
(I checked download from the web).
even if they're present in
C:\Program Files (x86)\Microsoft SDKs\ClickOnce Bootstrapper\Packages
When I deploy my setup installation fail because it can't download SqlClrTypes. If I install them using the same msi manually it works ok.
What can I do to make them install via ClickOnce ?
I'm using Visual Studio 2017, tried 2019 but the same thing happen.
EDIT: Fixed the issue with the prerequisites, my product.xml was referring to the wrong version for some reason. Now the setup is created without issue but when I try the installation it fails when downloading the msi. From the install.log it tries to download it from : http://go.microsoft.com/fwlink/?LinkID=221258

Can we install SQL Server standard edition using clickonce deployment of Visual Studio?

I'm trying to find ways while publishing application from Visual Studio 2015 to install SQL Server other than SQL Server Express edition if possible.
You can't. But if you need exactly SQL Express raw installation then you can to try this workaround:
You need to code application something like "net.Launcher", because ClickOnce application entry point (Launch .exe application) must be only .NET application. After client got it published, downloaded and executed - net.launcher.exe beginning download from some your local resource or server SQL Server installation package and saves it somewhere locally.
After download process down it's starts "sql express silent install" process and closing after finish. Don't forget to check installation status!
P.S. I didn't have seen any limitations about file size for manifest, so you can add package as zip archive or something like that as Binary content to you application (FCL have possibility uncompress it to temporary folder).

Oracle SQL Developer connection to Microsoft SQL Server

I have been trying without any success to get the latest version of Oracle SQL Developer (4.0.2) to connect to Microsoft SQL server using Windows authentication. I have downloaded and copied the ntmlauth.dll (and also JtdsXA.dll) file from jtds-1.3.1-dist to every location I can think of that developer would be looking for it but when I try and set up a new connection via the SQLServer tab clicking on the "Use Windows Authentication" option, all I get is the message "Status: Failure -I/O Error: SSO Failed: Native SSPI library not loaded. Check the java.library.path system property." I can however connect to the database using Toad for SQL Server or SSMS without any problems, but would prefer if possible to use SQL Developer.
Just copy ..\jtds-1.3.1-dist\x64\SSO\ntlmauth.dll to -> ..\sqldeveloper\jdk\jre\bin folder for x64 systems. Copy-paste similar folder contents for x86 systems as well.
I had the exact same problem. I eventually got it to work by placing the ntlmauth.dll in the jdk\jre\bin folder under the sql-developer directory itself. For some reason sql-developer ships with its own jdk, which I found by browsing around. I spent hours trying to figure out why the placement of the aforementioned DLL in the various system level jre directories (i.e. C:\Program Files\Java\jre7\bin) didn't work.
If anyone here knows why placement of ntlmauth.dll in the sql-developer\jdk\jre\bin folder worked while placement in the system level jre folders did not I would be interested.
My OS = Windows 2007 64-bit
jtds = jtds-1.2.7
The reason is pretty simple; SQLDEVELOPER doesn't know about the system level jre that was installed. Oracle bundles SQLDEVELOPER with and without JAVA. If you downloaded the one without java then when you first start the app you will be prompted for the location of the java_home. If you install the SQLDEVELOPER version that already has java installed then it just works -- no prompt. In your case, you installed the version with java already packaged with the app.
So the root of the question then is the system level jre is not used by SQLDEVELOPER (in your particular installation) so the ntlmauth.dll that you placed in that directory is never used.
After adding jTDS drivers (jtds-1.3.1) to Oracle SQL Developer (Tools->Preferences->Database->Third Party JDBC Drivers), I located the SQL Developer's ide.conf file and added the following lines:
#jTDS
Add64VMOption -Djava.library.path=../../drivers/jtds-1.3.1-dist/x64/SSO
Add32VMOption -Djava.library.path=../../drivers/jtds-1.3.1-dist/x86/SSO
This adds to JVM Library Path the location of ntlmauth.dll library

Embedding SQL Server into a .NET application

Hey, I've just finished writing a VB.NET application. Now I want to package the executable and the database ofcourse into a single installer file. I tried using QSetup, InstallShield to make SQL Server embedded into the setup file, and finally after hours of try&fail I have no idea. Anyone?
You can do a rightmouse on the properties of your Visual Studio Setup Project, and then there is this button 'Prerequisites'. There you can tick 'SQL Server Express ...' Or the 'SQL Server Compact 3.5'
link to image
You're probably best off just to set the connection file directly to the mdf, and attach it when the program is run. This is easier as it doesn't require a custom setup script to install the database to the database directory itself.
Note: Consider using the Compact Version, it's smaller, people don't like a full blown engine on their computer :)
InstallShield has a concept called Setup Prerequisites where you can teach it how to install additional packages along with your own. In older versions this would happen before calling your MSI. In newer versions you can have a "Feature" prerequisite where the prereq can associated to a feature and only installed if that feature is selected to be installed and after it's been selected but still before the main activity of your MSI occurs during the install execute sequence.
InstallShield also has a pattern for executing SQL scripts against your database instance so that you can then load your database into your newly installed instance.
All of this is quite powerful but it does take a bit of digging to learn.
As far as I know, anything but the SQL Server Compact Edition (SQL Server CE) cannot be embedded into your setup, really. Microsoft doesn't want that - you need to have SQL Server Express installed separately - any other edition can't even be shipped with your software (the client must have a license and installation separately).
You can indeed distribute SQL server with your custom application:
http://msdn.microsoft.com/en-us/library/bb264562(SQL.90).aspx

Resources