定期我得到以下异常:

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

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

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

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

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


当前回答

I got the same problem. However, finally, I can fix it. Currently, I use Visual Studio 2013 Community Edition. I just use Add->Existing Item... and browse to where the SQLite.Data.SQLite files are in (my case is 'C:\Program Files (x86)\System.Data.SQLite\2013\bin'). Please don't forget to change type of what you will include to Assembly Files (*.dll; *.pdb). Choose 'SQLite.Interop.dll' in that folder. From there and then, I can continue without any problems at all. Good luck to you all. ^_^ P.S. I create web form application. I haven't tried in window form application or others yet.

其他回答

我正在做一个简单的控制台应用程序,向SQLite数据库添加一些测试数据,并得到这个错误。项目的配置是“Any CPU”。我通过将SQLite.Interop.dll复制到bin\debug文件夹来修复它。更好的方法是使用@Wil的方法,但是如何为“任何CPU”配置指定该方法呢?

升级到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"

复制SQLite.Interop.dll到项目目录。

src\
  project\
      bin\   <-- Past in bin
         x64\
           SQLite.Interop.dll <-- Copy this if 64
         x86\
           SQLite.Interop.dll <-- Copy this if 32

这对我来说很管用。

With Visual Studio open, search and install SQLite.Core via the NUGET Package manager. Go to Solution Explorer in VS, Right click your PROJECT NAME-->ADD-->NEW FOLDER Name the folder x64 Repeat the process and add folder and name it x86 Right click the x64 folder-->ADD-->EXISTING ITEM Then browse to the DEBUG FOLDER. You will find the x64 folder. Open it and select the "SQLite.Interop.dll" file then hit OK. Repeat step 5 for the x86 folder. Right click the DLL that you just added and select PROPERTIES. In the option Copy to Output Directory, choose Copy always. Repeat step 7 for both DLLs in x64 and x86 folder.

下次构建该项目并使用另一台计算机时,它应该可以正常工作。

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

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

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

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