定期我得到以下异常:

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

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

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

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

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


当前回答

一个对我有效的解决方案是从nuget包中安装System.Data.SQLite。

导入要导入的项目的.dll,并安装System.Data.SQLite。

这将安装与您的解决方案/项目兼容并更新的ddl。

其他回答

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.

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

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

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

大会上会有竞争吗?检查DLL上是否有其他具有文件锁的应用程序。

如果是这个原因,使用Sysinternal的Process Explorer之类的工具来发现有问题的程序应该很容易。

HTH, 粘土

旧项目文件格式

即以<Project ToolsVersion="3.5" DefaultTargets="Build"开头的项目xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

将以下内容添加到“主”/根项目的csproj中

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

新的SDK项目文件格式

例如,以<Project Sdk="Microsoft.NET.Sdk.*"开头的项目>

将PrivateAssets="none"添加到System.Data.Sqlite PackageImport依赖链中的每个ProjectReference/PackageImport

ex:

<PackageReference Include="System.Data.SQLite.Core" Version="1.0.110" PrivateAssets="none"/>

正如SQLite wiki所说,你的应用程序部署必须是:

所以你要遵守规则。找到与您的目标平台匹配的dll,并将其放在图片中描述的位置。dll可以在YourSolution/packages/System.Data.SQLite.Core.%version%/中找到。

我有应用程序部署的问题,所以我只是添加了正确的SQLite.Interop.dll到我的项目中,在安装项目中添加了x86文件夹到applicicationfolder,并添加了文件引用到dll。