定期我得到以下异常:

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

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

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

阻止它的唯一方法就是退出并重新登录。不抛出异常并加载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/

其他回答

如果您试图在64位项目中运行32位dll,也可能会出现此错误。

当我在x86和x64文件夹中放置相同的文件(32位版本的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”。

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

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.

因此,在添加了NuGet之后,部署不会复制Interops。你可以把这个添加到你的csproj文件中,它应该会修复这个行为:

 <PropertyGroup> 
    <ContentSQLiteInteropFiles>true</ContentSQLiteInteropFiles>
    <CopySQLiteInteropFiles>false</CopySQLiteInteropFiles>
    <CleanSQLiteInteropFiles>false</CleanSQLiteInteropFiles>
    <CollectSQLiteInteropFiles>false</CollectSQLiteInteropFiles>
 </PropertyGroup>

如果你看一下NuGet for SQLite的源代码,你可以看到这些具体在做什么。这允许我使用ASP进行部署。净的核心。