定期我得到以下异常:

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

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

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

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

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


当前回答

如果您下载了正确的SQLite二进制文件,则根据项目构建选项将SQLite. interop .dll复制到您的发布或调试文件夹中。

其他回答

你需要通过NuGet安装System.Data.SQLite.Core。 如果您使用InnoSetup,请确保在.iss文件的[Files]部分中有以下行:

Source: "C:\YourProjectPath\bin\Release\x64\*"; DestDir: "{app}\x64"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: "C:\YourProjectPath\bin\Release\x86\*"; DestDir: "{app}\x86"; Flags: ignoreversion recursesubdirs createallsubdirs

更改项目的路径“YourProjectPath”。

我尝试了几乎所有的解决方案,但没有任何运气。最终解决这个问题的方法是将我选择的平台对应的SQLite.Interop.dll的副本直接放在我的安装项目的根目录下。

我不知道为什么它起作用了,但它确实起了作用。

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

我自己也遇到过这个问题,但事实证明是另一个原因:

System.DllNotFoundException was caught 
Unable to load DLL 'SQLite.Interop.dll': Access is denied. 

在这种情况下,代码是从IIS托管的web服务(为x86版本配置)中(间接地)调用的。我最终在IIS的应用程序池中找到了它:最初我使用的是“ASP。NET V4.0集成”(这导致了这个错误),但当我把它改成“DefaultAppPool”时,问题就消失了。

(唷!)

Mine didn't work for unit tests either, and for some reason Michael Bromley's answer involving DeploymentItem attribute didn't work. However, I got it working using test settings. In VS2013, add a new item to your solution and search for "settings" and select the "Test Settings" template file. Name it "SqliteUnitTests" or something and open it. Select "Deployment" off to the right, and add Directory/File. Add paths/directories to your SQLite.Interop.dll file. For me, I added two paths, one each for Project\bin\Debug\x64 and Console\bin\Debug\x86. You may also want to add your Sqlite file, depending on how you expect your unit test/solution to access the file.