定期我得到以下异常:
无法加载DLL 'SQLite.Interop.dll':无法找到指定的模块。(异常来自HRESULT: 0x8007007E)
我使用的是1.0.82.0。在VS2010, Win7 64操作系统下使用nuget安装。
一旦异常开始出现,它就会不断出现——在调试和发布中,在VS内部或外部运行应用程序。
阻止它的唯一方法就是退出并重新登录。不抛出异常并加载dll。 它可以工作几天,但之后又会坏掉。
有人见过这样的情况吗,有解决方案吗?
定期我得到以下异常:
无法加载DLL 'SQLite.Interop.dll':无法找到指定的模块。(异常来自HRESULT: 0x8007007E)
我使用的是1.0.82.0。在VS2010, Win7 64操作系统下使用nuget安装。
一旦异常开始出现,它就会不断出现——在调试和发布中,在VS内部或外部运行应用程序。
阻止它的唯一方法就是退出并重新登录。不抛出异常并加载dll。 它可以工作几天,但之后又会坏掉。
有人见过这样的情况吗,有解决方案吗?
当前回答
简而言之
为了让它也能与NCrunch一起工作,我必须在NCrunch配置中添加与NuGet包一起提供的Interop.dll版本作为附加文件。
我的情况
我有一个c#解决方案,其中一个项目直接依赖于SQLite(一个帮助库)和一个使用这个帮助库的单元测试项目。我已经安装了System.Data.SQLite.Core版本1.0.97.0作为NuGet包。
在我的案例中,Marin提供的解决方案使它可以在Visual Studio和CI中工作。然而,这仍然会在NCrunch中提供错误。
在NCrunch配置中,我在单元测试项目设置下的“附加文件”中添加了以下路径:
..\packages\System.Data.SQLite.Core.1.0.97.0\build\net45\**.dll
其他回答
我知道我来晚了,但在我今天下载了最新的x86/x64(版本1.0.88.0)后,我就遇到了这个问题。我在VS2012中的本地IIS默认运行32位,没有简单的方法切换到x64。我的生产服务器运行64位。
无论如何,我安装了NuGet包到一个DLL项目,我得到了这个错误。为了让它工作,我必须把它安装到主站点项目中。即使它根本不涉及SQLite类。
我的猜测是SQLite使用入口程序集来检测要加载哪个版本的Interop。
你需要通过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”。
升级到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"
我自己也遇到过这个问题,但事实证明是另一个原因:
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.