SQL Server Compact 错误:无法加载 DLL“sqlceme35.dll”。找不到指定的模块
我正在使用 Visual Studio 2008 C# 开发一个 Windows 窗体 应用程序,该应用程序使用 客户端上的 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 位上)时,它安装得很好,但是当我运行该应用程序时,出现此错误:
无法加载 DLL“sqlceme35.dll”。找不到指定的模块
我已经花了几个小时搜索这个错误,但我所能找到的只是与在 64 位 Windows 上安装相关的问题,而没有与我正在使用的普通 32 位 Windows 相关的问题。
安装应用程序将找到的所有依赖文件复制到指定的安装目录中,包括 System.Data.SqlServerCe.dll 文件(程序集版本 3.5.1.0)。数据库文件位于应用程序目录外名为“data”的目录中,它的连接字符串是
<add name="Tix.ieOutlet.Properties.Settings.TixLocalConnectionString" connectionString="Data Source=|DataDirectory|\data\TixLocal.sdf" providerName="Microsoft.SqlServerCe.Client.3.5" />
我有一些问题:
- 如果 DLL 文件位于同一目录(即应用程序本地目录)中,应用程序是否应该能够找到 DLL 文件,或者我是否需要将其安装在 GAC 中? (如果是这样,我可以使用 Windows Installer 在 GAC 中安装 DLL 文件吗?)
- 为了使用 SQL Server Compact 数据库,我还需要随应用程序分发其他内容吗?
- 还有其他 DLL 文件,例如用于将数据导出到客户端上的 Excel 的 MS interop。这些是否需要安装在 GAC 中,还是将它们放在应用程序目录中就足够了?
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="Tix.ieOutlet.Properties.Settings.TixLocalConnectionString" connectionString="Data Source=|DataDirectory|\data\TixLocal.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, i.e. 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您不需要将其置于 GAC 中即可运行 SQL Server Compact,它会从应用程序目录中选取它们。有多种方法可以部署 SQL Server Compact 项目。两种主要方法是:
在您的项目中部署 SQL Server Compact 可再发行安装程序,但这种方法很痛苦,而且可能会被最终用户卸载,或者通过 Windows 更新进行升级并破坏您的应用程序。
将 DLL 文件包含在您的应用程序文件夹中。根据您使用的 SQL Server Compact 的功能(复制或其他),您的应用程序文件夹中需要部署一些 DLL 文件。
如果您的计算机上安装了 SQL Server Compact,它们很可能位于“C:\Program Files\Microsoft SQL Server Compact Edition\v3.5”。可以将它们添加到 Visual Studio 中的项目中,然后将其项目输出类型设置为“始终复制”。项目引用中对
System.Data.SqlServerCe
的主要引用应将 copy local 设置为 true。如果您已完成所有这些设置,那么在您的安装程序项目中,您只需包含该项目的项目输出即可。在我看来,这是唯一的出路。这是一个简单的部署,由几个文件组成,您可以控制应用程序使用的 DLL 版本。
我希望这有帮助。
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.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.
我遇到了类似的问题,一个针对 32 位 Windows XP 和 Windows Vista 使用 SQL Server Compact 3.5 SP1 的 Visual Studio 2008 Windows 应用程序 - 当安装在 64 位 Windows 7 上时出现此错误:
我正在将 SQL Server Compact 的 MSI 嵌入到应用程序的安装程序中。
遵循这个相当混乱的MSDN 上的讨论 显示我需要在 64 位计算机上为 SQL Server Compact 使用 64 位 MSI。噢!也就是说,从页面 适用于 Windows 桌面的 Microsoft SQL Server Compact 3.5 Service Pack 1 和 Synchronization Services for ADO.NET version 1.0 Service Pack 1 我需要
SSCERuntime-ENU-x64.msi
而不是 64 位计算机的SSCERuntime-ENU-x86.msi
。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:
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 thanSSCERuntime-ENU-x86.msi
for 64-bit machines.如何:部署 SQL Server Compact Edition带有应用程序的数据库应该会有所帮助,至少可以解决您的前两个问题。
一般来说,我认为您不应该在 GAC 中为单个应用程序安装任何内容。
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.
下面提供了该问题的解决方案并进行了解释。
疑难解答:无法加载 SQL Server Compact DLL
应用程序第一个上的 SqlCeException使用 SQL Server Compact
Laxmi Narsimha Rao Oruganti 的博客
我希望这有帮助。
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.