定期我得到以下异常:

无法加载DLL 'SQLite.Interop.dll':无法找到指定的模块。(异常来自HRESULT: 0x8007007E)

我使用的是1.0.82.0。在VS2010, Win7 64操作系统下使用nuget安装。

一旦异常开始出现,它就会不断出现——在调试和发布中,在VS内部或外部运行应用程序。

阻止它的唯一方法就是退出并重新登录。不抛出异常并加载dll。 它可以工作几天,但之后又会坏掉。

有人见过这样的情况吗,有解决方案吗?


当前回答

这对我来说很管用。

With Visual Studio open, search and install SQLite.Core via the NUGET Package manager. Go to Solution Explorer in VS, Right click your PROJECT NAME-->ADD-->NEW FOLDER Name the folder x64 Repeat the process and add folder and name it x86 Right click the x64 folder-->ADD-->EXISTING ITEM Then browse to the DEBUG FOLDER. You will find the x64 folder. Open it and select the "SQLite.Interop.dll" file then hit OK. Repeat step 5 for the x86 folder. Right click the DLL that you just added and select PROPERTIES. In the option Copy to Output Directory, choose Copy always. Repeat step 7 for both DLLs in x64 and x86 folder.

下次构建该项目并使用另一台计算机时,它应该可以正常工作。

其他回答

当您处于这种状态时,尝试执行Rebuild-All。如果这解决了问题,您可能会遇到与我相同的问题。

一些背景(我的理解):

SQLite has 1 managed assembly (System.Data.SQLite.dll) and several platform specific assemblies (SQLite.Interop.dll). When installing SQLite with Nuget, Nuget will add the platform specific assemblies to your project (within several folders: \x86, \x64), and configures these dlls to "Copy Always". Upon load, the managed assembly will search for platform specific assemblies inside the \x86 and \x64 folders. You can see more on that here. The exception is this managed assembly attempting to find the relevant (SQLite.Interop.dll) inside these folders (and failing).

我的情况:

我的解决方案中有两个项目;一个WPF应用程序和一个类库。WPF应用程序引用类库,类库引用SQLite(通过Nuget安装)。

对我来说,问题是当我只修改WPF应用程序时,VS试图进行部分重建(意识到依赖的dll没有改变)。在这个过程的某个地方,VS清理了\x86和\x64文件夹的内容(清除了SQLite.Interop.dll)。当我做一个完整的Rebuild-All时,VS正确地复制文件夹及其内容。

我的解决方案:

为了解决这个问题,我添加了一个Post-Build进程,使用xcopy强制将\x86和\x64文件夹从类库复制到我的WPF项目\bin目录。

或者,您可以使用构建配置/输出目录做一些更花哨的事情。

我知道我来晚了,但在我今天下载了最新的x86/x64(版本1.0.88.0)后,我就遇到了这个问题。我在VS2012中的本地IIS默认运行32位,没有简单的方法切换到x64。我的生产服务器运行64位。

无论如何,我安装了NuGet包到一个DLL项目,我得到了这个错误。为了让它工作,我必须把它安装到主站点项目中。即使它根本不涉及SQLite类。

我的猜测是SQLite使用入口程序集来检测要加载哪个版本的Interop。

超过30个答案,但我用了不同的方法。

我有两个独立的项目。一个Windows服务,和一个Windows窗体应用程序。应用程序引用WS项目,两者都引用SQLite核心nuget包。

在构建WS项目时,有x64和x32文件夹。但在构建应用程序时,文件夹不会显示出来。

检查这里的答案,我不能让他们工作。但是我发现WS项目中有以下代码片段,而App项目中没有。我添加了它,现在文件夹显示正确。

<Import Project="..\packages\System.Data.SQLite.Core.1.0.112.0\build\net46\System.Data.SQLite.Core.targets" Condition="Exists('..\packages\System.Data.SQLite.Core.1.0.112.0\build\net46\System.Data.SQLite.Core.targets')" />

我的情况有点特殊。我在docker容器中运行一个应用程序,并不断得到以下错误

系统。DllNotFoundException:无法加载共享库'SQLite.Interop.dll'或其依赖项之一为了帮助诊断加载问题,可以考虑设置LD_DEBUG环境变量:libSQLite.Interop.dll:不能打开共享目标文件:没有这样的文件或目录

因此,我设置LD_DEBUG=libs,以找出System.Data.SQLite.dll正在查找的文件夹,以查找SQLite.Interop.dll。

你可以在这里找到关于设置LD_DEBUG的信息:http://www.bnikolic.co.uk/blog/linux-ld-debug.html

一旦我这样做了,我意识到SQLite.Interop.dll被找到了。没有找到的DLL是libSQLite.Interop.dll。我应该阅读整个错误消息。

在谷歌上搜索了几个小时后,我找到了这个关于如何从SQLite源代码编译缺失DLL的指南。

注意,实际丢失的文件是libSQLite.Interop.dll.so

编译源代码时,你会得到libsqlite。interop。so,你需要将它重命名为libsqlite。interop。dll。so,然后将它放到它要找的目录中你可以通过设置LD_DEBUG找到它。

对我来说,System.Data.SQLite.dll查找的目录是/usr/lib/x86_64-linux-gnu/

还添加了dll到测试项目(通过Nuget管理器),它修复了它。