定期我得到以下异常:

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

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

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

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

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


当前回答

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

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

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

其他回答

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

当我在x86和x64文件夹中放置相同的文件(32位版本的SQLite.Interop.dll)时,我得到了这个。

因为这个问题的复杂性,我想在这里发表。我的解决方案是回滚到。net 4.0。我已经测试了3天了,还不能让System.Data.SQLite.Core.1.0.98.0与. net 4.5或. net 4.5.1一起工作。

测试在3台计算机、2台服务器和一台开发PC上进行。我还没能找到问题的根源。我已经尝试编辑.vsproj文件。我已经将SQLite.interop.dll添加到所有文件夹中。我已经将包应用到所有GAC文件夹,并单独删除和重新应用。最终删除。

我有System.Data.SQLite.Core.1.0.98.0与。net 4.0一起工作。我打算继续尝试迁移,但我想我会先开始一个新项目,看看我是否能让它以那种方式工作。它最初是一个。net 3.5 web应用程序,在我的旅行中,我发现大量的信息仍然引用了这个框架。

我在运行Visual Studio Express 2013时也遇到了同样的问题。我尝试了这里和其他地方提到的几种解决方案,但都没有用。我希望这个修正能帮助到其他人。

我通过在测试基于sqlite的服务的测试类上使用deploymenttem属性来修复它。

例子:

[TestClass]
[DeploymentItem(@"x86\SQLite.Interop.dll", "x86")] // this is the key
public class LocalStoreServiceTests
{

    [TestMethod]
    public void SomeTestThatWasFailing_DueToThisVeryIssue()
    {
         // ... test code here
    }
}

这将导致所需的SQLite.Interop.dll被复制到适当的“TestResults”文件夹中的x86目录。

全是绿色的。一切都很好。

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.

升级到Visual Studio 2019版。16.10导致了我的问题,其中msbuild报告了以下System.Data.SQLite.Core-package:

CopySQLiteInteropFiles:
Skipping target "CopySQLiteInteropFiles" because it has no outputs.

https://github.com/dotnet/msbuild/issues/6493

微软表示,该漏洞已被修复。16.10.4. 现在只需要等待AppVeyor更新他们的Visual Studio图像(在此之前,可以使用以前的Visual Studio 2019)。

现在,AppVeyor正在为当前和以前的Visual Studio 2019-image使用破碎的dotnet-build-engine。现在一个必须显式安装dotnet sdk ver。5.0.302:

Invoke-WebRequest -Uri 'https://dot.net/v1/dotnet-install.ps1' -UseBasicParsing -OutFile "$env:temp/dotnet-install.ps1"; & $env:temp\dotnet-install.ps1 -Architecture x64 -Version 5.0.302 -InstallDir "$env:ProgramFiles\dotnet"