新的 SQLite 混合程序集

发布于 2024-11-11 07:50:40 字数 611 浏览 4 评论 0原文

以前,.NET SQLite 库可从 http://sqlite.phxsoftware.com 获取,但最近已被主要 SQLite 团队接管并已迁移System.Data.SQLite 下载页面。新的包似乎不再包含混合程序集(包含 sqlite3.dll 和 .NET 包装器的单个程序集)。

新包附带了 .NET DLL 和 SQLite.Interop.dll,根据文档,桌面上不需要这些文件,但我的应用程序无法加载,并显示“无法加载 DLL 'SQLite”。 Interop.DLL':找不到指定的模块。。我尝试在 IIS/IIS Express 下运行该应用程序,并将应用程序池设置为 32 位。

我尝试将 SQLite.Interop.dll 文件复制到 bin 文件夹、系统文件夹和 ASP.NET 临时文件夹中,但仍然出现相同的错误。

是否有任何地方都可以使用新版本的混合程序集?如果没有,是否有办法修复无法加载 DLL 'SQLite.Interop.DLL 错误?

Previously .NET SQLite libraries were available from http://sqlite.phxsoftware.com, but they have recently been taken over by the main SQLite team and have moved System.Data.SQLite Download Page. The new packages don't seem to contain mixed assemblies anymore (single assembly containing sqlite3.dll and the .NET wrapper).

The new package comes with the .NET DLL and SQLite.Interop.dll which based on the documentation is not needed on the desktop but my application fails to load with Unable to load DLL 'SQLite.Interop.DLL': The specified module could not be found.. I have tried running the application under IIS/IIS Express with apppool set to 32-bit.

I have tried copying the SQLite.Interop.dll file into the bin folder, the system folder, and the ASP.NET temp folder but still get the same error.

Are there mixed assemblies for new releases available anywhere? If not, is there a way to fix the Unable to load DLL 'SQLite.Interop.DLL error?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

冷了相思 2024-11-18 07:50:40

下载页面现在包含所有版本的“混合模式”下载System.Data.SQLite,其工作方式与早期版本的 SQLite 相同,即无需在项目中包含 SQLite.Interop.dll。

诀窍是 - 在下载链接中查找“bundle”一词,

例如 sqlite-netFx35-setup-bundle-x86-2008-1.0.76.0.exe

您还将看到这些的描述文本链接以“此安装包具有混合模式程序集”开头。

我被烧伤了,因为我没有意识到这实际上意味着“如果你想让它像以前一样工作,就下载这个”

由于不知道混合模式程序集的含义,其他链接似乎是更好的选择 - 因为它们声称“此安装包将安装所有必要的运行时组件和依赖项”。

另请注意,判断您是否得到“错误”的唯一方法是通过文件大小。这些 DLL 具有完全相同的名称和完全相同的版本号。 混合模式版本要大得多 - 大约 700K。另一张是160K左右。

真是一团乱啊……

The downloads page now contains "mixed mode" downloads for all variations of System.Data.SQLite, that work the same way as earlier versions of SQLite i.e. no requirement to also include SQLite.Interop.dll in your project.

The trick is - look for the word "bundle" in the download links

e.g. sqlite-netFx35-setup-bundle-x86-2008-1.0.76.0.exe

You will also see that the description text for these links begins with "This setup package features the mixed-mode assembly".

I got burned because I didn't realize that this really means "download this one if you want it to work the way it always did before".

Having no idea what was meant by a mixed-mode assembly, the other links seemed like a better option - because they claim "This setup package will install all the necessary runtime components and dependencies".

Also note that the only way to tell if you've gotten the "wrong" one is by file size. The DLLs have exactly the same name, and exactly the same version number. The mixed-mode version is much bigger - around 700K. The other one is around 160K.

What a mess...

独行侠 2024-11-18 07:50:40

我找到了解决方案。该问题是由于 SQLite.Interop 的已知问题造成的.dll。

这是对我有用的解决方法。

使用 Dependency Walker 从
http://dependencywalker.com/ 查看
在 SQLite.Interop.dll(x86 和 x64)
显示它依赖于MSVCR100.dll。

旧的1.0.66.0版本
System.Data.SQLite.dll 没有
这种依赖。随着目前
构建,我们将不得不重新分配
MSVCR100.dll 也或运行
来自 Microsoft 的安装程序。

解决方案:来自:
缺少 msvcr100.dll

使用静态链接。在
SQLite.Interop Visual Studio 项目。
转到此属性设置:项目
->属性->配置属性-> C/C++->代码生成
->运行时库并将值更改为多线程 (/MT)。 (这
当前源代码(1.0.71.0)有
多线程 DLL (/MD) 会导致
依赖 MSVCR100.dll 的 dll 和
DLLImport(和 LoadLibary())到
当用户没有它时失败)。

我认为静态链接应该是
已更改,因此它是默认值
SQLite.Interop.dll。

I found the solution. The problem was due to a known issue with SQLite.Interop.dll.

This is the workaround from that worked for me.

Using Dependency Walker from
http://dependencywalker.com/ to look
at SQLite.Interop.dll (x86 and x64)
shows that it depends on MSVCR100.dll.

The old 1.0.66.0 version of
System.Data.SQLite.dll does not have
this dependency. With the current
build, we would have to redistribute
that MSVCR100.dll also or run an
installer from Microsoft.

Solution: From:
Missing msvcr100.dll

Use static linking. In the
SQLite.Interop Visual Studio project.
Go to this Properties setting: Project
-> Properties -> Configuration Properties -> C/C++ -> Code Generation
-> Runtime Library and change the value to Multi-threaded (/MT). (The
current source code (1.0.71.0) has
Multi-threaded DLL (/MD) which causes
the dll to rely on MSVCR100.dll and
the DLLImport (and LoadLibary()) to
fail when users do not have it).

I believe static linking should be
changed so it is the default for
SQLite.Interop.dll.

提笔落墨 2024-11-18 07:50:40

我在不同应用程序的插件中遇到了同样的问题。就我而言,我通过修改环境变量 PreLoadSQLite_BaseDirectory 在第一次引用 SQLite 之前。

// Make SQLite work... (loading dll from e.g. x64/SQLite.Interop.dll)
System.Environment.SetEnvironmentVariable("PreLoadSQLite_BaseDirectory", System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location));

Sql.Data.SQLite...

我不明白为什么需要这样做,因为我认为 PreLoadSQLite_BaseDirectory (嗯,相应的内部变量)将默认为 System.Data.SQLite.dll 的位置> 文件。

I had the same issue, in a plugin for a different application. In my case I solved it by modifying the environment variable PreLoadSQLite_BaseDirectory before referencing SQLite for the first time.

// Make SQLite work... (loading dll from e.g. x64/SQLite.Interop.dll)
System.Environment.SetEnvironmentVariable("PreLoadSQLite_BaseDirectory", System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location));

Sql.Data.SQLite...

I don't see why this was required though, as I thought PreLoadSQLite_BaseDirectory (well, the corresponding internal variable) would default to the location of the System.Data.SQLite.dll file.

宣告ˉ结束 2024-11-18 07:50:40

在 64 位计算机上,AnyCPU 目标 .NET 应用程序无法加载 32 位 DLL 文件。您可能需要将 .NET 应用程序的平台目标设置为 x86 才能使其在 64 位和 32 位计算机上运行。

编辑:在幕后,您无法加载 Interop DLL 的原因可能是由于与本机 SQLite DLL 文件的位数不匹配而导致 BadImageFormatException

On 64-bit machines an AnyCPU targeted .NET application cannot load 32-bit DLL files. You likely will need to set the platform target of your .NET application to x86 in order to get it working on both the 64-bit and 32-bit machines.

Edit: under the hood the reason you can't load the Interop DLL is probably because of a BadImageFormatException due to the bitness mismatch with the native SQLite DLL file.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文