定期我得到以下异常:

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

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

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

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

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


当前回答

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

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

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

其他回答

这里确实有很多答案,但我的答案简单明了,没有gac。

问题是,可执行文件需要一个正确的SQLite.Interop.dll (x86或x64)的副本来访问我们的数据库。

大多数架构都有层,在我的例子中,数据层有SQLite连接所需的DLL。

所以我简单地把一个后构建脚本到我的数据层解决方案和一切工作良好。


TL; diana;

在构建选项中将解决方案的所有项目设置为x86或x64。 使用SQLite nuget包将以下Post-Build-Script添加到项目中: /y . xcopy "$(TargetDir)x64" "$(SolutionDir)bin\Debug\

当然,您必须更改发布构建和x86构建的脚本。


STL; diana;

将SQLite.Interop.dll放在*.exe文件旁边。

你需要通过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 'SQLite.Interop.dll'”异常。

区别项目的.csproj文件,这是在NON-WORKING版本中:

<ItemGroup>
     <Content Include="x64\SQLite.Interop.dll" />
     <Content Include="x86\SQLite.Interop.dll" />
</ItemGroup>

下面是WORKING版本的内容:

<ItemGroup>
     <Content Include="x64\SQLite.Interop.dll">
          <CopyToOutputDirectory>Always</CopyToOutputDirectory>
      </Content>
      <Content Include="x86\SQLite.Interop.dll">
          <CopyToOutputDirectory>Always</CopyToOutputDirectory>
      </Content>
</ItemGroup>

在返回之后,我没有收到异常。DLL文件被转储到适当的Debug\x64 (etc)文件夹中。

这对我来说很管用。

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.

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

简而言之

为了让它也能与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