定期我得到以下异常:

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

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

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

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

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


当前回答

超过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')" />

其他回答

I don't know why this has not been included yet, but I had to do the research and find this out for myself, so hopefully someone will find this answer and be saved the trouble. This was for a WPF app. It worked fine on my Dev box, but did not work on the computer where I was copying it and got the Unable to load DLL 'SQLite.Interop.dll' error. I ported over all of its associated directories and files, directly from my "Debug" folder to this other computer when I got the same error as the OP when I ran it. My "bin" folder that contained my DLLs had been copied to "Debug\bin" and all were included, along with my application files when I did my copying to the other computer using this path, so it was not missing any files.

我在其他答案中看到的不适用的东西:

I did not use the NuGet package or need to create x86 or x64 folders that it seems that NuGet package creates. My DLLs (System.Data.SQLite and SQLite.Interop.dll, along with System.Data.SQLite.config) are in the "bin" folder in my project and were copied in manually (create "bin" folder in Solution Explorer in VS, paste DLLs into this folder in Windows Explorer, use Add > Existing Item to bring files into VS folder/project). Then I reference them as Referenced Assemblies in my project using that location ("References" > "Add Reference", and browse to one, rinse, repeat for the rest). This ensures my project knows exactly where they are. I did not need to reference any SQLite DLL file in my app.config or even touch my MyProject.csproj file. I did not even need to specify a particular processor! My project's build is for "Any CPU", even though I have only mixed or 64-bit DLLs and will only be running on Windows 7+, which are 64-bit OSes. (no x86-only/32-bit solely DLLs) I was already specifying them as "Content" and "copy if newer" for these DLLs when I experienced the OP's error.

我从https://system.data.sqlite.org/index.html/doc/trunk/www/faq.wiki#q20上找到了这个:

(11) Why do I get a DllNotFoundException (for "sqlite3.dll" or "SQLite.Interop.dll") when trying to run my application? Either the named dynamic link library (DLL) cannot be located or it cannot be loaded due to missing dependencies. Make sure the named dynamic link library is located in the application directory or a directory along the system PATH and try again. Also, be sure the necessary Visual C++ runtime redistributable has been installed unless you are using a dynamic link library that was built statically linked to it.

我要强调这段内粗体的部分。目标计算机是新的,除了. net 4.0之外没有加载任何程序。一旦我安装了c++,它就能够完成SQLite的命令。这应该是第一个常见问题之一,也是先决条件的一部分,但它被埋在了第11位。我的开发计算机已经加载了它,因为它带有Visual Studio,所以这就是它在那里工作的原因。

下载: Visual c++ Redistributable for Visual Studio 2015 https://www.microsoft.com/en-us/download/details.aspx?id=48145

更新3(累积更新): https://www.microsoft.com/en-us/download/details.aspx?id=53587

我的情况有点特殊。我在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/

对于任何关注这个问题的人来说:

如果您使用nuget包,它会安装一个构建规则,为您执行复制。(参见System.Data.SQLite.Core.1.0.94.0\build -或任何你安装的Core版本)。

nuget安装程序会自动将规则添加到项目文件中。

但是,这仍然不能解决测试用例问题。deploymenttem (https://stackoverflow.com/a/24411049/89584)方法似乎是惟一可行的方法。

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

我也有同样的问题。请遵循以下步骤:

确保你已经安装了System.Data.SQLite.Core包 来自NuGet的SQLite开发团队。 转到项目解决方案,并尝试在包文件夹内找到构建文件夹 检查您的项目框架并选择所需的SQLite.Interop.dll并将其放置在调试/发布文件夹中

参考