SQL Server Compact 错误:无法加载 DLL 'sqlceme35.dll'.指定的模块无法找到 [英] SQL Server Compact error: Unable to load DLL 'sqlceme35.dll'. The specified module could not be found

查看:46
本文介绍了SQL Server Compact 错误:无法加载 DLL 'sqlceme35.dll'.指定的模块无法找到的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Visual Studio 2008 C# 开发 Windows Forms 应用程序,该应用程序使用 <客户端上的 href="http://en.wikipedia.org/wiki/SQL_Server_Compact" rel="nofollow noreferrer">SQL Server Compact 3.5 数据库.客户端很可能是 32 位 Windows XP 或 Windows Vista 机器.我正在使用一个标准的 Windows Installer 项目,该项目创建了一个 MSI 文件和 setup.exe 来安装客户端计算机上的应用程序.我是 SQL Server Compact 的新手,所以我以前不必像这样分发客户端数据库.当我运行 setup.exe(在带有 SP2 和 Internet Explorer 7 的新 Windows XP 32 位上)时,它安装正常,但是当我运行应用程序时,我收到此错误:

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:

无法加载 DLL 'sqlceme35.dll'.找不到指定的模块

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

我已经花了几个小时来搜索这个错误,但我能找到的只是与在 64 位 Windows 上安装有关的问题,而没有与我正在使用的普通 32 位有关的问题.

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.

安装应用程序将它找到的所有依赖文件复制到指定的安装目录中,包括 System.Data.SqlServerCe.dll 文件(程序集版本 3.5.1.0).数据库文件位于应用程序目录下名为data"的目录中,其连接字符串为

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" />

我的一些问题:

  • 如果 DLL 文件位于同一目录中,即应用程序本地,应用程序是否应该能够找到该 DLL 文件,或者我是否需要将其安装在 GAC?(如果是这样,我可以使用 Windows 安装程序在 GAC 中安装 DLL 文件吗?)
  • 为了使用 SQL Server Compact 数据库,我还需要随应用程序分发什么吗?
  • 还有其他 DLL 文件,例如用于在客户端将数据导出到 Excel 的 MS 互操作.这些是否需要安装在 GAC 中或将它们放在应用程序目录中就足够了?
  • 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?

推荐答案

SQL Server Compact 的运行不需要它在 GAC 中,它会从应用程序目录中提取它们.有多种方法可以部署 SQL Server Compact 项目.两种主要方式是:

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:

  1. 在您的项目中部署 SQL Server Compact 可再发行安装程序,但这种方式很痛苦,而且最终用户可能会卸载,或者通过 Windows 更新升级并破坏您的应用程序.

  1. 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.

在您的应用程序文件夹中包含 DLL 文件.根据您使用的 SQL Server Compact 的功能(复制或其他),有少量 DLL 文件要部署在您的应用程序文件夹中.

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.

如果您的计算机上安装了 SQL Server Compact,它们很可能位于C:\Program Files\Microsoft SQL Server Compact Edition\v3.5".可以将它们添加到 Visual Studio 中的项目,然后将它们的项目输出类型设置为始终复制".项目引用中对 System.Data.SqlServerCe 的主要引用应该将 copy local 设置为 true.

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

如果您已经设置了所有这些,那么在您的安装程序项目中,您只需要包含该项目的项目输出就可以了.在我看来,这是唯一的出路.这是一个简单的部署,由几个文件组成,您可以控制您的应用程序使用的 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.

希望能帮到你.

这篇关于SQL Server Compact 错误:无法加载 DLL 'sqlceme35.dll'.指定的模块无法找到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆