简体   繁体   English

无法加载 DLL“SQLite.Interop.dll”

[英]Unable to load DLL 'SQLite.Interop.dll'

Periodically I am getting the following exception:我定期收到以下异常:

Unable to load DLL 'SQLite.Interop.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)

I am using 1.0.82.0.我正在使用 1.0.82.0。 version, installing it with nuget in VS2010, OS Win7 64.版本,在 VS2010,操作系统 Win7 64 中使用 nuget 安装它。

Once exception starts to appear, it appears constantly - in debug and release and running application within or outside VS.一旦异常开始出现,它就会不断出现——在 VS 内部或外部的调试、发布和运行应用程序中。

The only way to stop it is logoff and logon.停止它的唯一方法是注销和登录。 The exception is not thrown and dll is loaded.不抛出异常并加载 dll。 It can work for days, but then it can break again.它可以工作几天,但随后可能会再次损坏。

Has anyone seen something like this and is there a solution for it?有没有人见过这样的事情,有解决办法吗?

I know I'm late to the party but I had this issue right after I pulled down latest x86/x64 today (version 1.0.88.0).我知道我参加聚会迟到了,但是在我今天下载最新的 x86/x64(版本 1.0.88.0)之后,我就遇到了这个问题。 My local IIS in VS2012 runs 32bit by default and there's no easy way to switch to x64.我在 VS2012 中的本地 IIS 默认运行 32 位,并且没有简单的方法可以切换到 x64。 My production server runs 64bit.我的生产服务器运行 64 位。

Anyway I installed the NuGet package to a DLL project and I got this error.无论如何,我将 NuGet 包安装到 DLL 项目中,但出现此错误。 What I had to do to get it working I had to install it to the main site project, too.我必须做些什么才能让它工作,我也必须将它安装到主站点项目中。 Even if it doesn't touch SQLite classes at all.即使它根本不涉及 SQLite 类。

My guess is that SQLite uses the entry assembly to detect which version of Interop to load.我的猜测是 SQLite 使用入口程序集来检测要加载哪个版本的互操作。

I had this problem because a dll I was using had Sqlite as a dependency (configured in NuGet with only the Sqlite core package.).我遇到这个问题是因为我使用的 dll 将 Sqlite 作为依赖项(在 NuGet 中仅配置了 Sqlite 核心包。)。 The project compiles and copies all the Sqlite dll-s except the 'SQLite.Interop.dll' (both x86 and x64 folder).该项目编译并复制除“SQLite.Interop.dll”(x86 和 x64 文件夹)之外的所有 Sqlite dll。

The solution was very simple: just add the System.Data.SQLite.Core package as a dependency (with NuGet) to the project you are building/running and the dll-s will be copied.解决方案非常简单:只需将 System.Data.SQLite.Core 包作为依赖项(使用 NuGet)添加到您正在构建/运行的项目中,并且 dll-s 将被复制。

So, after adding the NuGet the deployment doesn't copy down the Interops.因此,在添加 NuGet 之后,部署不会复制互操作。 You can add this to your csproj file and it should fix that behavior:您可以将其添加到您的 csproj 文件中,它应该可以修复该行为:

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

If you look in the source for NuGet for SQLite you can see what these are doing specifically.如果您查看 NuGet for SQLite 的源代码,您可以看到它们具体在做什么。 This allowed me to get a deploy working with ASP.Net Core.这使我能够使用 ASP.Net Core 进行部署。

I had this same problem when using SQLite in a WPF project whose platform target was Any CPU .在平台目标为Any CPU的 WPF 项目中使用 SQLite 时,我遇到了同样的问题。 I fixed it by following the following steps:我按照以下步骤修复了它:

  1. Open the project designer in Visual Studio.在 Visual Studio 中打开项目设计器。 Details on how to do it can be found here .可以在此处找到有关如何操作的详细信息。
  2. Click on the Build tab.单击构建选项卡。
  3. Disable the prefer 32-bit option.禁用prefer 32-bit选项。

Alternatively, you could just set the platform target to x86 or x64 .或者,您可以将平台目标设置为x86x64 I think this problem is caused by the System.Data.SQLite library using the platform target to get the location of the 'SQLite.Interop.dll' file.我认为这个问题是由System.Data.SQLite库使用平台目标来获取“SQLite.Interop.dll”文件的位置引起的。

UPDATE:更新:

In case the project designer cannot be reached, just open the project ( *.csproj ) file from a text editor and add the value <Prefer32Bit>false</Prefer32Bit> into the <PropertyGroup>...</PropertyGroup> tag.如果无法联系到项目设计者,只需从文本编辑器打开项目 ( *.csproj ) 文件并将值<Prefer32Bit>false</Prefer32Bit><PropertyGroup>...</PropertyGroup>标记中。

Example code示例代码

<PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <ProjectGuid>[Set by Visual Studio]</ProjectGuid>
    <OutputType>Exe</OutputType>
    <AppDesignerFolder>Properties</AppDesignerFolder>
    <RootNamespace>[Set by Visual Studio]</RootNamespace>
    <AssemblyName>[Set by Visual Studio]</AssemblyName>
    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
    <FileAlignment>[Set by Visual Studio]</FileAlignment>
    <!--Add the line below to your project file. Leave everything else untouched-->
    <Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>

This is how I fixed it in my project.这就是我在我的项目中修复它的方式。

It was working, and when a colleague submitted his changes, I received the "Unable to load DLL 'SQLite.Interop.dll'" exception.它正在工作,当一位同事提交他的更改时,我收到了“无法加载 DLL 'SQLite.Interop.dll'”异常。

Diffing the project's .csproj file, this was in the NON-WORKING version:比较项目的 .csproj 文件,这是在非工作版本中:

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

And this is what the WORKING version had:这就是 WORKING 版本所具有的:

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

After reverting back, I didn't receive the exception.恢复后,我没有收到异常。 The DLL files were dumped in the appropriate Debug\\x64 (etc) folders. DLL 文件被转储到相应的 Debug\\x64 (etc) 文件夹中。

When you get in this state, try performing a Rebuild-All.当您进入此状态时,请尝试执行 Rebuild-All。 If this fixes the problem, you may have the same issue I had.如果这解决了问题,您可能会遇到与我相同的问题。

Some background (my understanding) :一些背景(我的理解)

  • SQLite has 1 managed assembly (System.Data.SQLite.dll) and several platform specific assemblies (SQLite.Interop.dll). SQLite 有 1 个托管程序集 (System.Data.SQLite.dll) 和几个特定于平台的程序集 (SQLite.Interop.dll)。 When installing SQLite with Nuget, Nuget will add the platform specific assemblies to your project (within several folders: \\x86, \\x64), and configures these dlls to "Copy Always".使用 Nuget 安装 SQLite 时,Nuget 会将特定于平台的程序集添加到您的项目(在几个文件夹中:\\x86、\\x64),并将这些 dll 配置为“始终复制”。

  • Upon load, the managed assembly will search for platform specific assemblies inside the \\x86 and \\x64 folders.加载时,托管程序集将在 \\x86 和 \\x64 文件夹中搜索特定于平台的程序集。 You can see more on that here .您可以在此处了解更多信息 The exception is this managed assembly attempting to find the relevant (SQLite.Interop.dll) inside these folders (and failing).例外是这个托管程序集试图在这些文件夹中找到相关的(SQLite.Interop.dll)(并且失败)。

My Scenario :我的场景

I have 2 projects in my solution;我的解决方案中有 2 个项目; a WPF app, and a class library.一个 WPF 应用程序和一个类库。 The WPF app references the class library, and the class library references SQLite (installed via Nuget). WPF 应用程序引用类库,类库引用 SQLite(通过 Nuget 安装)。

The issue for me was when I modify only the WPF app, VS attempts to do a partial rebuild (realizing that the dependent dll hasn't changed).我的问题是当我只修改 WPF 应用程序时,VS 尝试进行部分重建(意识到依赖的 dll 没有改变)。 Somewhere in this process, VS cleans the content of the \\x86 and \\x64 folders (blowing away SQLite.Interop.dll).在此过程中,VS 会清除 \\x86 和 \\x64 文件夹的内容(清除 SQLite.Interop.dll)。 When I do a full Rebuild-All, VS copies the folders and their contents correctly.当我进行完整的 Rebuild-All 时,VS 会正确复制文件夹及其内容。

My Solution :我的解决方案

To fix this, I ended up adding a Post-Build process using xcopy to force copying the \\x86 and \\x64 folders from the class library to my WPF project \\bin directory.为了解决这个问题,我最终添加了一个使用 xcopy 的 Post-Build 过程来强制将 \\x86 和 \\x64 文件夹从类库复制到我的 WPF 项目 \\bin 目录。

Alternatively, you could do fancier things with the build configuration / output directories.或者,您可以使用构建配置/输出目录做更有趣的事情。

I had the same issue running Visual Studio Express 2013. I tried several solutions mentioned here and elsewhere to no avail.我在运行 Visual Studio Express 2013 时遇到了同样的问题。我尝试了这里和其他地方提到的几种解决方案,但无济于事。 I hope this fix helps others.我希望这个修复可以帮助其他人。

I fixed it by using the DeploymentItem attribute on my test class that tests the SQLite-based service.我通过在测试基于 SQLite 的服务的测试类上使用DeploymentItem属性来修复它。

Example:例子:

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

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

This causes the needed SQLite.Interop.dll to get copied to the x86 directory within the appropriate "TestResults" folder.这会导致所需的SQLite.Interop.dll被复制到适当的“TestResults”文件夹中的x86目录。

All is green.一切都是绿色的。 All is good.一切都很好。

Tools -> Extension and updates更新 NuGet Tools -> Extension and updates并使用命令PM> Update-Package -reinstall System.Data.SQLite.Core重新安装 SQLite.Core 为我修复了它。

I had a similar issue in a multiple projects solution.我在多项目解决方案中遇到了类似的问题。 The SQLite.Interop.dll was necessary for one of the plugins distributed with the software using ClickOnce. SQLite.Interop.dll 是使用 ClickOnce 随软件分发的插件之一所必需的。

As far as debugging in visual studio everything worked fine, but the deployed version was missing the folders x86/ and x64/ containing that DLL.至于在 Visual Studio 中调试,一切正常,但部署的版本缺少包含该 DLL 的文件夹 x86/ 和 x64/。

The solution to have it work after deployment using ClickOnce was to create in the startup project of the solution (also the one being published) these two subfolder, copy into them the DLLs and set them as Content Copy Always.使用 ClickOnce 部署后使其工作的解决方案是在解决方案的启动项目(也是正在发布的项目)中创建这两个子文件夹,将 DLL 复制到它们中并将它们设置为 Content Copy Always。

This way the ClickOnce publishing tool automatically includes these files and folders in the manifest and deploys the software with them这样 ClickOnce 发布工具会自动将这些文件和文件夹包含在清单中,并使用它们部署软件

There are really a lot of answers here, but mine is simple and clear with no-GAC-playing-around .这里确实有很多答案,但我的答案简单明了,没有 GAC-playing-around

The problem was, the executable File needs a copy of the right SQLite.Interop.dll (x86 or x64) to access our Database.问题是,可执行文件需要正确的SQLite.Interop.dll (x86 或 x64)的副本才能访问我们的数据库。

Mostly architectures have layers and in my case the Data Layer has the required DLL for SQLite Connection.大多数架构都有层,在我的情况下,数据层具有 SQLite 连接所需的 DLL。

So i simple put a post build script into my Data Layer Solution and everything worked fine.所以我简单地将后期构建脚本放入我的数据层解决方案中,一切正常。


TL;DR; TL; 博士;

  1. Set all Projects of your solution to x86 or x64 in the build options.在构建选项中将解决方案的所有项目设置为x86x64

  2. Add following Post-Build-Script to the Project with the SQLite nuget Package :使用SQLite nuget Package将以下Post-Build-Script添加到项目中:

    xcopy "$(TargetDir)x64" "$(SolutionDir)bin\\Debug\\" /y

Of course you have to change the script for Release Build and x86 builds.当然,您必须更改Release Buildx86版本的脚本。


STL;DR; STL; DR;

Put your SQLite.Interop.dll next to the *.exe File.将您的SQLite.Interop.dll放在*.exe文件旁边。

old project file format旧项目文件格式

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

Add the following to your csproj on your "main"/root project将以下内容添加到“main”/root 项目上的 csproj

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

new SDK project file format新的 SDK 项目文件格式

ie projects beginning with <Project Sdk="Microsoft.NET.Sdk.*">即以<Project Sdk="Microsoft.NET.Sdk.*">开头的<Project Sdk="Microsoft.NET.Sdk.*">

Add PrivateAssets="none" to each ProjectReference/PackageImport in the dependency chain down to the System.Data.Sqlite PackageImportPrivateAssets="none"添加到依赖链中的每个 ProjectReference/PackageImport 直到 System.Data.Sqlite PackageImport

ex:前任:

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

The default installation of the multi-architecture (x86, x64) version of SQLite from NuGet exhibits the behavior that you described.来自 NuGet 的 SQLite 多体系结构(x86、x64)版本的默认安装表现出您描述的行为。 If you would like to load the correct version for actual architecture that the .NET runtime chose to run your application on your machine, then you can give the DLL loader a hint about where to locate the correct library as follows:如果您想为 .NET 运行时选择在您的机器上运行您的应用程序的实际架构加载正确的版本,那么您可以向 DLL 加载程序提供有关在何处找到正确库的提示,如下所示:

Add a declaration for the kernel32.dll function call to SetDLLDirectory() before your Program.Main():在你的 Program.Main() 之前添加一个 kernel32.dll 函数调用到 SetDLLDirectory() 的声明:

    [System.Runtime.InteropServices.DllImport("kernel32.dll", CharSet = System.Runtime.InteropServices.CharSet.Unicode, SetLastError = true)]
    [return: System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.Bool)]
    static extern bool SetDllDirectory(string lpPathName);

Then use your own method for determining the correct subdirectory to find the architecture specific version of 'SQLite.Interop.dll'.然后使用您自己的方法来确定正确的子目录以查找“SQLite.Interop.dll”的体系结构特定版本。 I use the following code:我使用以下代码:

    [STAThread]
    static void Main()
    {
        int wsize = IntPtr.Size;
        string libdir = (wsize == 4)?"x86":"x64";
        string appPath = System.IO.Path.GetDirectoryName(Application.ExecutablePath);
        SetDllDirectory(System.IO.Path.Combine(appPath, libdir));

even if it is an old post, I'd like to share the solution that I found here: http://system.data.sqlite.org/index.html/info/54e52d4c6f即使是旧帖子,我也想分享我在这里找到的解决方案: http : //system.data.sqlite.org/index.html/info/54e52d4c6f

If you don't want to read all the issue, the solution is to copy the file "msvcr100.dll" (that can be found in Windows\\System32 directory) in the same path as SQLite.Interop.dll.如果您不想阅读所有问题,解决方案是将文件“msvcr100.dll”(可以在 Windows\\System32 目录中找到)复制到与 SQLite.Interop.dll 相同的路径中。

I would advice to read the issue to understand why, and to include the file in your setup but to install it only if the error occurs, I made it an optional component selectable in the setup options.我建议阅读该问题以了解原因,并将该文件包含在您的设置中,但仅在发生错误时才安装它,我将其设置为可在设置选项中选择的可选组件。

HTH, Formentz HTH, 福门茨

I don't know why this has not been included yet, but I had to do the research and find this out for myself, so hopefully someone will find this answer and be saved the trouble.我不知道为什么这还没有被包括在内,但我必须做研究并为自己找到这个,所以希望有人能找到这个答案并省去麻烦。 This was for a WPF app.这是一个 WPF 应用程序。 It worked fine on my Dev box, but did not work on the computer where I was copying it and got the Unable to load DLL 'SQLite.Interop.dll' error.它在我的开发箱上运行良好,但在我复制它的计算机上不起作用,并出现Unable to load DLL 'SQLite.Interop.dll'错误。 I ported over all of its associated directories and files, directly from my "Debug" folder to this other computer when I got the same error as the OP when I ran it.当我运行它时遇到与 OP 相同的错误时,我将其所有关联的目录和文件直接从我的“调试”文件夹移植到另一台计算机。 My "bin" folder that contained my DLLs had been copied to "Debug\\bin" and all were included, along with my application files when I did my copying to the other computer using this path, so it was not missing any files.包含我的 DLL 的“bin”文件夹已被复制到“Debug\\bin”,并且当我使用此路径复制到另一台计算机时,所有文件以及我的应用程序文件都被包含在内,因此它没有丢失任何文件。

Things I saw said in other answers that did not apply:我在其他答案中看到的内容不适用:

  • I did not use the NuGet package or need to create x86 or x64 folders that it seems that NuGet package creates.我没有使用 NuGet 包或需要创建似乎是 NuGet 包创建的 x86 或 x64 文件夹。 My DLLs (System.Data.SQLite and SQLite.Interop.dll, along with System.Data.SQLite.config) are in the "bin" folder in my project and were copied in manually (create "bin" folder in Solution Explorer in VS, paste DLLs into this folder in Windows Explorer, use Add > Existing Item to bring files into VS folder/project).我的 DLL(System.Data.SQLite 和 SQLite.Interop.dll,以及 System.Data.SQLite.config)位于我项目的“bin”文件夹中,并被手动复制(在解决方案资源管理器中创建“bin”文件夹) VS,将 DLL 粘贴到 Windows 资源管理器中的此文件夹中,使用添加 > 现有项目将文件放入 VS 文件夹/项目中)。 Then I reference them as Referenced Assemblies in my project using that location ("References" > "Add Reference", and browse to one, rinse, repeat for the rest).然后我在我的项目中使用该位置(“参考”>“添加参考”,并浏览到一个, 冲洗,重复其余部分)将它们作为参考程序集引用。 This ensures my project knows exactly where they are.这确保我的项目确切地知道它们在哪里。
  • I did not need to reference any SQLite DLL file in my app.config or even touch my MyProject.csproj file.我不需要在我的 app.config 中引用任何 SQLite DLL 文件,甚至不需要接触我的 MyProject.csproj 文件。
  • I did not even need to specify a particular processor!我什至不需要指定特定的处理器! My project's build is for "Any CPU", even though I have only mixed or 64-bit DLLs and will only be running on Windows 7+, which are 64-bit OSes.我的项目构建适用于“任何 CPU”,即使我只有混合或 64 位 DLL,并且只能在 64 位操作系统的 Windows 7+ 上运行。 (no x86-only/32-bit solely DLLs) (没有 x86-only/32-bit only DLLs)
  • I was already specifying them as "Content" and "copy if newer" for these DLLs when I experienced the OP's error.当我遇到 OP 的错误时,我已经将它们指定为这些 DLL 的“内容”和“如果更新则复制”。

What I found was this, from https://system.data.sqlite.org/index.html/doc/trunk/www/faq.wiki#q20 :我发现的是这个,来自https://system.data.sqlite.org/index.html/doc/trunk/www/faq.wiki#q20

(11) Why do I get a DllNotFoundException (for "sqlite3.dll" or "SQLite.Interop.dll") when trying to run my application? (11) 为什么我在尝试运行我的应用程序时会得到一个 DllNotFoundException(对于“sqlite3.dll”或“SQLite.Interop.dll”)?

Either the named dynamic link library (DLL) cannot be located or it cannot be loaded due to missing dependencies. 无法找到指定的动态链接库 (DLL),或者由于缺少依赖项而无法加载。 Make sure the named dynamic link library is located in the application directory or a directory along the system PATH and try again. 确保命名的动态链接库位于应用程序目录或系统 PATH 中的目录中,然后重试。 Also, be sure the necessary Visual C++ runtime redistributable has been installed unless you are using a dynamic link library that was built statically linked to it. 此外,请确保已安装必要的 Visual C++ 运行时可再发行组件,除非您使用的是静态链接到它的动态链接库。

Emphasis mine on that bolded part inside the paragraph.强调我在段落内的粗体部分。 The target computer was fresh and had no programs loaded except .NET 4.0.目标计算机是全新的,除 .NET 4.0 外没有加载任何程序。 Once I installed C++, it was able to complete the commands to SQLite.一旦我安装了 C++,它就能够完成 SQLite 的命令。 This should have been one of the first FAQs and part of the pre-requisities, but it was buried at #11.这应该是第一个常见问题解答之一,也是先决条件的一部分,但它被埋在了#11。 My development computer already had it loaded because it came with Visual Studio, so that's why it worked, there.我的开发计算机已经加载了它,因为它带有 Visual Studio,这就是它在那里工作的原因。

Download:下载:
Visual C++ Redistributable for Visual Studio 2015:适用于 Visual Studio 2015 的 Visual C++ 可再发行组件:
https://www.microsoft.com/en-us/download/details.aspx?id=48145 https://www.microsoft.com/en-us/download/details.aspx?id=48145

Update 3 (cumulative update):更新 3(累积更新):
https://www.microsoft.com/en-us/download/details.aspx?id=53587 https://www.microsoft.com/en-us/download/details.aspx?id=53587

As the SQLite wiki says, your application deployment must be:正如SQLite wiki所说,您的应用程序部署必须是:

应用部署

So you need to follow the rules.所以你需要遵守规则。 Find dll that matches your target platform and put it in location, describes in the picture.找到与您的目标平台匹配的dll并将其放置在位置,如图所示。 Dlls can be found in YourSolution/packages/System.Data.SQLite.Core.%version%/. DLL 可以在 YourSolution/packages/System.Data.SQLite.Core.%version%/ 中找到。

I had problems with application deployment, so I just added right SQLite.Interop.dll into my project, the added x86 folder to AppplicationFolder in setup project and added file references to dll.我在应用程序部署方面遇到了问题,所以我只是将正确的 SQLite.Interop.dll 添加到我的项目中,将 x86 文件夹添加到安装项目中的 AppplicationFolder 并添加了对 dll 的文件引用。

Copy "SQLite.Interop.dll" files for both x86 and x64 in debug folder.在调试文件夹中复制 x86 和 x64 的“SQLite.Interop.dll”文件。 these files should copy into "x86" and "x64 folders in debug folder.这些文件应复制到调试文件夹中的“x86”和“x64”文件夹中。

I had the same issue.我遇到过同样的问题。 Please follow these steps:请按照以下步骤操作:

  1. Make sure you have installed System.Data.SQLite.Core package by SQLite Development Team from NuGet .确保你已经安装了来自NuGet SQLite Development Team System.Data.SQLite.Core包。
  2. Go to project solution and try to locate build folder inside packages folder转到项目解决方案并尝试在packages文件夹中找到build文件夹
  3. Check your project framework and pick the desired SQLite.Interop.dll and place it in your debug/release folder检查您的项目框架并选择所需的 SQLite.Interop.dll 并将其放在您的调试/发布文件夹中

Reference参考

You could also get this error if you are trying to run a 32 bit dll, in a 64 bit project.如果您尝试在 64 位项目中运行 32 位 dll,您也可能会收到此错误。

I got this when I have placed the same file(SQLite.Interop.dll in 32 bit version) in both the x86 and x64 folder.当我在 x86 和 x64 文件夹中放置相同的文件(32 位版本的 SQLite.Interop.dll)时,我得到了这个。

如果您为SQLite下载了正确的二进制文件,则根据您的项目构建选项将SQLite.Interop.dll复制到您的ReleaseDebug文件夹中。

I have started using Costura.Fody to package (.net) assemblies and embed and preload native dlls.我已经开始使用 Costura.Fody 来打包 (.net) 程序集并嵌入和预加载本机 dll。 This also helps later, with distribution as you can send one file.这也有助于以后分发,因为您可以发送一个文件。

  1. Install Costura Fody from Nuget.从 Nuget 安装 Costura Fody。

  2. In your C# project create a folder called costrua32.在您的 C# 项目中,创建一个名为 costrua32 的文件夹。 In there add any native dlls you which C# to load.在那里添加要加载的 C# 的任何本机 dll。

  3. Once you have added them to this folder.将它们添加到此文件夹后。 Click on the properties window and change build action to "Embedded Resource"单击属性窗口并将构建操作更改为“嵌入式资源”

  4. Finally you need to amend the XML file called FodyWeavers.xml as follows.最后,您需要修改名为 FodyWeavers.xml 的 XML 文件,如下所示。 Here I am specifying load the sql dll first.这里我指定首先加载 sql dll。 (note you drop the .dll) (注意你删除了 .dll)

     Weavers Costura PreloadOrder SQLite.Interop tbb_debug tbb /PreloadOrder> /Costura /Weavers

The advantage of this is that you do not have to write any pre or post build events, and the end product is totally encapsulated in to one larger file.这样做的好处是您不必编写任何构建前或构建后事件,并且最终产品完全封装在一个更大的文件中。

我遇到这个问题是因为我的 PC 中没有安装 Visual C++ 2010 可再发行组件。如果您还没有安装 Visual c++ 2010 可再发行组件,请下载并安装它(检查 x86 或 64 dll)。

I got the same problem.我遇到了同样的问题。 However, finally, I can fix it.但是,最后,我可以修复它。 Currently, I use Visual Studio 2013 Community Edition.目前,我使用 Visual Studio 2013 社区版。 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').我只是使用Add->Existing Item...并浏览到 SQLite.Data.SQLite 文件所在的位置(我的例子是'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) .请不要忘记更改您将包含到程序集文件 (*.dll; *.pdb) 的内容的类型 Choose ' SQLite.Interop.dll ' in that folder.在该文件夹中选择“ SQLite.Interop.dll ”。 From there and then, I can continue without any problems at all.从那时起,我可以继续没有任何问题。 Good luck to you all.祝大家好运。 ^_^ PS I create web form application. ^_^ PS 我创建网络表单应用程序。 I haven't tried in window form application or others yet.我还没有尝试过窗体应用程序或其他应用程序。

在构建之前尝试将平台目标设置为 x86 或 x64(而不是任何 CPU):Visual Studio 中的项目->属性->构建->平台目标。

Copy SQLite.Interop.dll in project directory.复制项目目录中的 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

I've struggled with this for a long time, and, occasionally, I found that the test setting is incorrect.我为此苦苦挣扎了很长时间,偶尔,我发现测试设置不正确。 See this image:看这张图片:测试设置

I just uncheck the test setting, and the issue disappears.我只是取消选中测试设置,问题就消失了。 Otherwise, the exception will occurs.否则会出现异常。 Hopefully, this will help someone.希望这会对某人有所帮助。 Not sure it's the root cause.不确定这是根本原因。

My application is a web application (ASP.NET MVC) and I had to change the application pool to run under LocalSystem instead of ApplicationPoolIdentity .我的应用程序是一个 Web 应用程序 (ASP.NET MVC),我不得不更改应用程序池以在LocalSystem而不是ApplicationPoolIdentity下运行。 To do this:去做这个:

  1. Open IIS Manager打开 IIS 管理器
  2. Find the Application Pool your site is running under.找到您的站点在其下运行的应用程序池。
  3. Click Advanced Settings from the actions从操作中单击高级设置
  4. Change Identity to LocalSystem将身份更改为LocalSystem

I have no idea why this fixes the issue.我不知道为什么这可以解决问题。

还将 dll 添加到测试项目(通过 Nuget Manager)并修复它。

Upgrading to Visual Studio 2019 ver.升级到 Visual Studio 2019 版本。 16.10 caused the issue for me, where msbuild reported the following for the System.Data.SQLite.Core -package: 16.10 给我造成了这个问题,其中 msbuild 报告了System.Data.SQLite.Core的以下内容:

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

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

Microsoft says the bug has been fixed with ver.微软表示该错误已在版本中修复。 16.10.4. 16.10.4. Now just have to wait for AppVeyor to update their Visual Studio Images (Until then one can use Previous Visual Studio 2019 ).现在只需要等待 AppVeyor 更新他们的 Visual Studio 图像(在此之前可以使用Previous Visual Studio 2019 )。

Now AppVeyor is using broken dotnet-build-engine for both current and previous Visual Studio 2019-image.现在,AppVeyor 正在对当前和以前的 Visual Studio 2019 映像使用损坏的 dotnet-build-engine。 Now one have to explicit install dotnet sdk ver.现在必须显式安装 dotnet sdk 版本。 5.0.302: 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"

Could there be contention for the assembly?大会会不会有争执? Check to see whether there's another application with a file lock on the DLL.检查是否有另一个应用程序在 DLL 上锁定了文件。

If this is the reason, it should be easy to use a tool like Sysinternal's Process Explorer to discover the offending program.如果这是原因,那么使用Sysinternal 的 Process Explorer 之类的工具来发现有问题的程序应该很容易。

HTH, Clay HTH, 粘土

我不知道这是否是一个好的答案,但我能够通过在具有“本地系统”标识的 AppDomain 下运行我的应用程序来解决这个问题。

I am working on a simple console application to add some test data to an SQLite database and was getting this error.我正在开发一个简单的控制台应用程序,将一些测试数据添加到 SQLite 数据库中,但出现此错误。 The configuration for the project is "Any CPU".项目的组态为“任何 CPU”。 I fixed it by copying the SQLite.Interop.dll to the bin\\debug folder.我通过将 SQLite.Interop.dll 复制到 bin\\debug 文件夹来修复它。 A better way would be to use the method by @Wil, but how do you specify this for "Any CPU" configuration?更好的方法是使用@Wil 的方法,但是如何为“任何 CPU”配置指定此方法?

For reference for anyone looking at this question: 供查看此问题的人参考:

If you use the nuget package, it installs a build rule that does the copying for you. 如果您使用nuget包,它会安装一个构建规则,为您执行复制。 (see under System.Data.SQLite.Core.1.0.94.0\\build - or whatever version of Core you install). (请参阅System.Data.SQLite.Core.1.0.94.0 \\ build - 或您安装的任何Core版本)。

The nuget installer adds the rule to your project file automatically. nuget安装程序会自动将规则添加到项目文件中。

This still doesn't fix the test case problem though. 但这仍然无法解决测试用例问题。 The DeploymentItem ( https://stackoverflow.com/a/24411049/89584 ) approach is the only thing that seems to work there. DeploymentItem( https://stackoverflow.com/a/24411049/89584 )方法似乎是唯一可行的方法。

I ran across this problem, in a solution with a WebAPI/MVC5 web project and a Feature Test project, that both drew off of the same data access (or, 'Core') project. 我在一个带有WebAPI / MVC5 Web项目和功能测试项目的解决方案中遇到了这个问题,它们都使用了相同的数据访问(或“核心”)项目。 I, like so many others here, am using a copy downloaded via NuGet in Visual Studio 2013. 我和其他许多人一样,在Visual Studio 2013中使用通过NuGet下载的副本。

What I did, was in Visual Studio added a x86 and x64 solution folder to the Feature Test and Web Projects. 我所做的是,在Visual Studio中为功能测试和Web项目添加了一个x86和x64解决方案文件夹。 I then did a Right Click | Add Existing Item... 然后我做了Right Click | Add Existing Item... Right Click | Add Existing Item... , and added the appropriate SQLite.interop.dll library from ..\\SolutionFolder\\packages\\System.Data.SQLite.Core.1.0.94.0\\build\\net451\\[appropriate architecture] for each of those folders. Right Click | Add Existing Item... ,并为每个文件夹中的..\\SolutionFolder\\packages\\System.Data.SQLite.Core.1.0.94.0\\build\\net451\\[appropriate architecture]添加适当的SQLite.interop.dll库。 I then did a Right Click | Properties 然后我做了Right Click | Properties Right Click | Properties , and set Copy to Output Directory to Always Copy . Right Click | Properties ,并将“ Copy to Output Directory设置为“ Always Copy The next time I needed to run my feature tests, the tests ran successfully. 下次我需要运行我的功能测试时,测试成功运行。

In short 简而言之

To get this to work also with NCrunch I had to add the Interop.dll versions provided with the NuGet package as additional files in NCrunch configuration . 为了使这个也与NCrunch一起工作,我不得不将随NuGet包提供的Interop.dll版本添加为NCrunch配置中的附加文件

My case 我的情况

I had a C# solution with one project directly depending on SQLite (a helper library) and a unit test project that used this helper library. 我有一个C#解决方案,其中一个项目直接依赖于SQLite(一个帮助程序库)和一个使用这个帮助程序库的单元测试项目。 I had installed System.Data.SQLite.Core version 1.0.97.0 as a NuGet package. 我已经将System.Data.SQLite.Core版本1.0.97.0安装为NuGet包。

In my case the workaround provided by Marin got it working in Visual Studio and in CI as well. 在我的例子中,Marin提供解决方法使其在Visual Studio和CI中工作。 However this would still provide errors in NCrunch. 然而,这仍然会在NCrunch中提供错误。

In NCrunch configuration I added the following path in "Additional files to include" under the unit test projects settings: 在NCrunch配置中,我在单元测试项目设置下的“要包括的附加文件”中添加了以下路径:

..\packages\System.Data.SQLite.Core.1.0.97.0\build\net45\**.dll

I wanted to posted here because of the complexity of this problem.由于这个问题的复杂性,我想在这里发布。 My solution was to roll back to .Net 4.0.我的解决方案是回滚到 .Net 4.0。 I have been testing for 3 days and have not been able to get System.Data.SQLite.Core.1.0.98.0 to work with .Net 4.5 or .Net 4.5.1.我已经测试了 3 天,但无法让 System.Data.SQLite.Core.1.0.98.0 与 .Net 4.5 或 .Net 4.5.1 一起使用。

The testing was exhaustive on 3 computers, 2 servers one dev PC.在 3 台计算机、2 台服务器和一台开发 PC 上进行了详尽的测试。 I have not been able to get to the source of the issue.我一直无法找到问题的根源。 I have tried editing the .vsproj file.我试过编辑 .vsproj 文件。 I have added the SQLite.interop.dll to all folders practically.我实际上已将 SQLite.interop.dll 添加到所有文件夹中。 I have applied the package to all GAC folders, and removed and reapplied individually.我已将该包应用于所有 GAC 文件夹,并单独删除并重新应用。 Eventually removed.最终被移除。

I do have System.Data.SQLite.Core.1.0.98.0 working with .Net 4.0.我确实有 System.Data.SQLite.Core.1.0.98.0 与 .Net 4.0 一起工作。 I intend to continue to attempt the migration, but I think I will start a new project first and see if I can get it to work in that fashion.我打算继续尝试迁移,但我想我会先开始一个新项目,看看我是否可以让它以这种方式工作。 This was originally a .Net 3.5 web app, and in my travels I found a good amount of information still referencing that framework.这最初是一个 .Net 3.5 网络应用程序,在我的旅行中,我发现大量信息仍在引用该框架。

My situation was a little unique.我的情况有点特殊。 I was running an application inside a docker container and kept getting the following error我在 docker 容器中运行一个应用程序并不断收到以下错误

System.DllNotFoundException : Unable to load shared library 'SQLite.Interop.dll' or one of its dependencies. System.DllNotFoundException:无法加载共享库“SQLite.Interop.dll”或其依赖项之一。 In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: libSQLite.Interop.dll: cannot open shared object file: No such file or directory为了帮助诊断加载问题,请考虑设置 LD_DEBUG 环境变量:libSQLite.Interop.dll: cannot open shared object file: No such file or directory

So I set LD_DEBUG=libs to find out what folders System.Data.SQLite.dll was looking in to find SQLite.Interop.dll .所以我设置LD_DEBUG=libs来找出System.Data.SQLite.dll正在寻找哪些文件夹来查找SQLite.Interop.dll

You can find info on setting LD_DEBUG here: http://www.bnikolic.co.uk/blog/linux-ld-debug.html您可以在此处找到有关设置LD_DEBUG 的信息: http : //www.bnikolic.co.uk/blog/linux-ld-debug.html

Once I did that I realized that SQLite.Interop.dll was being found just fine.一旦我这样做了,我意识到SQLite.Interop.dll被找到就好了。 The DLL that wasn't being found was libSQLite.Interop.dll .未找到的 DLL 是libSQLite.Interop.dll I should have read the entire error message.我应该阅读整个错误信息。

Hours of Googling later I found this guide on how to compile the missing DLL from the SQLite source code.经过数小时的谷歌搜索,我找到了有关如何从 SQLite 源代码编译丢失的 DLL 的指南

Note that the file that was actually missing was libSQLite.Interop.dll.so请注意,实际丢失的文件是libSQLite.Interop.dll.so

Anyway when you compile the source code you get libSQLite.Interop.so which you need to rename to libSQLite.Interop.dll.so and put it in the directory that it's looking in which you can find by setting LD_DEBUG .无论如何,当您编译源代码时,您会得到libSQLite.Interop.so ,您需要将其重命名为libSQLite.Interop.dll.so并将其放在它正在查找的目录中,您可以通过设置LD_DEBUG找到该目录。

For me the directory that System.Data.SQLite.dll was looking in was /usr/lib/x86_64-linux-gnu/对我来说System.Data.SQLite.dll正在查找的目录是/usr/lib/x86_64-linux-gnu/

You do need to install System.Data.SQLite.Core via NuGet.您确实需要通过 NuGet 安装 System.Data.SQLite.Core。 If you use InnoSetup, make sure that you have the following lines in the [Files] section of the .iss file:如果您使用 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

Change ' YourProjectPath ' for the path to your project.将“ YourProjectPath ”更改为项目的路径。

I encountered this problem myself, but it turned out to be another cause:我自己也遇到过这个问题,但后来证明是另外一个原因:

System.DllNotFoundException was caught 
Unable to load DLL 'SQLite.Interop.dll': Access is denied. 

In this case, the code was (indirectly) called from a web-service hosted by IIS (configured for x86 build).在这种情况下,代码是(间接)从 IIS 托管的 Web 服务(为 x86 构建配置)调用的。 I finally tracked it down to the Application Pool in IIS: Originally I was using "ASP.NET V4.0 Integrated" (which resulted in that error), but when I changed it over to "DefaultAppPool" , the problem went away.我终于将其追踪到 IIS 中的应用程序池:最初我使用的是“ASP.NET V4.0 Integrated” (导致该错误),但是当我将其更改为“DefaultAppPool”时,问题就消失了。

(Phew!) (呸!)

So, my issue was that SQLite was trying to load at design-time in WPF.所以,我的问题是 SQLite 试图在设计时在 WPF 中加载。 Since I cared only about x86 environment, I set the CPU preference to that and copied SQLite.Interop.dll from the Nuget package to the root directory of the solution.由于我只关心 x86 环境,因此我将 CPU 首选项设置为该选项并将 SQLite.Interop.dll 从 Nuget 包复制到解决方案的根目录。 Restarted the solution and all problems disappeared.重新启动解决方案,所有问题都消失了。 So, if you're having design-time issues, put the library into the root directory of your solution.因此,如果您遇到设计时问题,请将库放入解决方案的根目录中。

Additionally, I was getting a similar issue during runtime, so I had to place a copy of SQLite.Interop.dll into my project and set it to copy if it's newer in the properties.此外,我在运行时遇到了类似的问题,因此我必须将 SQLite.Interop.dll 的副本放入我的项目中,并在属性中将其设置为复制。 It appears that x86 and x64 folders provided are completely useless.提供的 x86 和 x64 文件夹似乎完全没用。 Further investigation is required, but overall... it's just easier to manually reference SQLite in your project than to use a Nuget package.需要进一步调查,但总的来说……在项目中手动引用 SQLite 比使用 Nuget 包更容易。

Additionally, the official FAQ states the following:此外,官方常见问题解答指出以下内容:

(20) When the System.Data.SQLite project is compiled and run from inside Visual Studio, why do I get a DllNotFoundException or a BadImageFormatException (for "sqlite3.dll" or "SQLite.Interop.dll") when trying to run or debug the application? (20) 当 System.Data.SQLite 项目从 Visual Studio 内部编译和运行时,为什么我在尝试运行或调试应用程序?

When compiling and running a solution from within Visual Studio that uses the System.Data.SQLite project (including the test project), it is very important to select the correct build configuration and platform.在 Visual Studio 中编译和运行使用 System.Data.SQLite 项目(包括测试项目)的解决方案时,选择正确的生成配置和平台非常重要。 First, managed applications to be debugged inside Visual Studio cannot use the mixed-mode assembly (ie because it is always compiled to the platform-specific build output directory).首先,要在 Visual Studio 中调试的托管应用程序不能使用混合模式程序集(即因为它始终编译到特定于平台的构建输出目录)。 This is necessary to properly support building binaries for multiple platforms using the same source project files.这对于正确支持使用相同源项目文件为多个平台构建二进制文件是必要的。 Therefore, only the "DebugNativeOnly" or "ReleaseNativeOnly" build configurations should be selected when running a managed application from inside Visual Studio that relies upon the System.Data.SQLite assembly.因此,从依赖 System.Data.SQLite 程序集的 Visual Studio 内部运行托管应用程序时,应仅选择“DebugNativeOnly”或“ReleaseNativeOnly”构建配置。 These build configurations contain a custom post-build step that copies the required native assembly to the managed output directory (ie to enable running the managed binaries in-place).这些构建配置包含一个自定义的构建后步骤,该步骤将所需的本机程序集复制到托管输出目录(即,启用就地运行托管二进制文件)。 However, this post-build step will only be performed if the selected platform matches that of the operating system (eg "Win32" for 32-bit Windows and "x64" for 64-bit Windows).但是,只有在所选平台与操作系统匹配时才会执行此构建后步骤(例如,“Win32”适用于 32 位 Windows,“x64”适用于 64 位 Windows)。 Therefore, it is good practice to double-check the selected build platform against the operating system prior to attempting to run a managed project in the solution.因此,在尝试在解决方案中运行托管项目之前,最好根据操作系统仔细检查所选的构建平台。

https://system.data.sqlite.org/index.html/doc/trunk/www/faq.wiki#q20 https://system.data.sqlite.org/index.html/doc/trunk/www/faq.wiki#q20

Mine didn't work for unit tests either, and for some reason Michael Bromley's answer involving DeploymentItem attribute didn't work.我的也不适用于单元测试,并且由于某种原因,Michael Bromley 涉及 DeploymentItem 属性的答案不起作用。 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.在 VS2013 中,向您的解决方案添加一个新项目并搜索“设置”并选择“测试设置”模板文件。 Name it "SqliteUnitTests" or something and open it.将其命名为“SqliteUnitTests”或其他名称并打开它。 Select "Deployment" off to the right, and add Directory/File.选择右侧的“部署”,然后添加目录/文件。 Add paths/directories to your SQLite.Interop.dll file.将路径/目录添加到您的 SQLite.Interop.dll 文件。 For me, I added two paths, one each for Project\\bin\\Debug\\x64 and Console\\bin\\Debug\\x86.对我来说,我添加了两条路径,分别用于 Project\\bin\\Debug\\x64 和 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.您可能还想添加 Sqlite 文件,具体取决于您希望单元测试/解决方案如何访问该文件。

Expanding on Kugel's answer which worked for me (VS2015 Enterprise) leveraging SQLite from a dll the Nuget package can be removed from the main project after building and testing:扩展对我有用的 Kugel 答案(VS2015 Enterprise)利用 dll 中的 SQLite,在构建和测试后,可以从主项目中删除 Nuget 包:

1.Install Nuget package to main project. 1.安装Nuget包到主项目。

Install-Package System.Data.SQLite

2.Build Application and test that your Sqlite connection is working: 2.构建应用程序并测试您的 Sqlite 连接是否正常工作:

select * from sqlite_master

3.Uninstall Nuget package from the main build. 3.从主构建中卸载 Nuget 包。

UnInstall-Package System.Data.SQLite

4.Manually remove the dll references for SQLite and EntityFramework: 4.手动删除SQLite和EntityFramework的dll引用:

System.Data.SQLite
System.Data.SQLite.EF6
System.Data.SQLite.Linq
  1. Remove Xml references from the main project's “packages.config” xml file.从主项目的“packages.config”xml 文件中删除 Xml 引用。

This worked for me and keeps my project clean.这对我有用并保持我的项目干净。

In the Nuget package of SQLLite Core there is a the file System.Data.SQLite.Core.targets .在 SQLLite Core 的Nuget 包中有一个文件System.Data.SQLite.Core.targets Just include this in all projects that use the this library and all libraries that used your library.只需将其包含在使用此库的所有项目和使用您的库的所有库中。

In yours .csproj or .vbproj files add: Every time you compile in your bin will added x86 and x64 directory with the SQLite.Interop.dll file.在您的 .csproj 或 .vbproj 文件中添加: 每次您在 bin 中编译时都会添加 x86 和 x64 目录以及 SQLite.Interop.dll 文件。

刚刚为我工作:在包管理器控制台上Install-Package System.Data.SQLite.Core

This is what worked for me.这对我有用。

  1. With Visual Studio open, search and install SQLite.Core via the NUGET Package manager.打开 Visual Studio,通过 NUGET 包管理器搜索并安装 SQLite.Core。
  2. Go to Solution Explorer in VS, Right click your PROJECT NAME-->ADD-->NEW FOLDER转到 VS 中的解决方案资源管理器,右键单击您的项目名称-->添加-->新文件夹
  3. Name the folder x64将文件夹命名为 x64
  4. Repeat the process and add folder and name it x86重复该过程并添加文件夹并将其命名为 x86
  5. Right click the x64 folder-->ADD-->EXISTING ITEM Then browse to the DEBUG FOLDER.右键单击 x64 文件夹-->ADD-->EXISTING ITEM 然后浏览到 DEBUG 文件夹。 You will find the x64 folder.您将找到 x64 文件夹。 Open it and select the "SQLite.Interop.dll" file then hit OK.打开它并选择“SQLite.Interop.dll”文件,然后点击“确定”。
  6. Repeat step 5 for the x86 folder.对 x86 文件夹重复步骤 5。
  7. Right click the DLL that you just added and select PROPERTIES.右键单击您刚刚添加的 DLL 并选择属性。 In the option Copy to Output Directory, choose Copy always.在选项复制到输出目录中,选择始终复制。
  8. Repeat step 7 for both DLLs in x64 and x86 folder.对 x64 和 x86 文件夹中的两个 DLL 重复步骤 7。

Next time you build the project and take to another computer, it should work fine.下次构建项目并将其带到另一台计算机时,它应该可以正常工作。

I tried pretty much all of the solutions here without any luck.我在这里尝试了几乎所有的解决方案,但没有任何运气。 Finally solved it by putting a copy of the SQLite.Interop.dll corresponding to my selected platform directly under the root of my setup project.最后通过将与我选择的平台对应的 SQLite.Interop.dll 的副本直接放在我的安装项目的根目录下来解决它。

I have no idea why it worked but it did.我不知道为什么它有效,但确实有效。

Over 30 answers, and yet I solved it in a different way.超过 30 个答案,但我以不同的方式解决了它。

I had 2 separate projects.我有 2 个独立的项目。 A Windows Service, and a Windows Forms app.一个 Windows 服务和一个 Windows 窗体应用程序。 The App references the WS project, and both reference the SQLite Core nuget package. App 引用了 WS 项目,并且都引用了 SQLite Core nuget 包。

When building the WS project, the x64 and x32 folders are there.构建 WS 项目时,x64 和 x32 文件夹都在那里。 But when building the App, the folders don't show up.但是在构建应用程序时,文件夹不显示。

Checking the answers here, I couldn't make them work.检查这里的答案,我无法让它们工作。 But I figured out that the following snippet was present in the WS project, and was missing in the App project.但我发现以下代码片段存在于 WS 项目中,而在 App 项目中却没有。 I added it, and the folders now show up correctly.我添加了它,文件夹现在正确显示。

<Import Project="..\packages\System.Data.SQLite.Core.1.0.112.0\build\net46\System.Data.SQLite.Core.targets" Condition="Exists('..\packages\System.Data.SQLite.Core.1.0.112.0\build\net46\System.Data.SQLite.Core.targets')" />

我发现当我允许 Nuget 将 SQLite 更新到 1.0.115.5 时,我的项目不再需要“SQLite.Interop.dll”。

I came up with a solution.我想出了一个解决方案。

In my case, I am using Microsoft Visual Studio Installer Project.就我而言,我使用的是 Microsoft Visual Studio Installer Project。 The setup project does not see the x64 and x86 folders and contents from primary outputs.安装项目看不到主要输出中的 x64 和 x86 文件夹和内容。

Solution:解决方案:

  1. Add both the x64 and x86 folders to the Application Folder in Setup.将 x64 和 x86 文件夹添加到安装程序中的应用程序文件夹。
  2. Add the contents of both folders.添加两个文件夹的内容。

This will allow the setup to copy the DLL files needed for SQLite to work.这将允许安装程序复制 SQLite 工作所需的 DLL 文件。

I hope you are well.我希望你一切都好。

One solution that worked for me was to install System.Data.SQLite from the nuget package.一种对我有用的解决方案是从 nuget 包中安装 System.Data.SQLite。

Import the.dlls of the project you want to import and install System.Data.SQLite.导入你要导入的项目的.dll,安装System.Data.SQLite。

This will install the ddl compatible and updated with your solution/project.这将安装与您的解决方案/项目兼容和更新的 ddl。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法加载SQLite.Interop.dll - Unable to Load SQLite.Interop.dll “无法在客户端计算机上加载DLL&#39;SQLite.Interop.dll&#39;错误 - "Unable to load DLL 'SQLite.Interop.dll' error on client machine 无法在NUnit中使用nHibernate加载DLL&#39;SQLite.Interop.dll&#39; - Unable to load DLL 'SQLite.Interop.dll' with nHibernate in NUnit 部分客户端无法加载 SQLite.Interop.dll - Some clients are unable to load SQLite.Interop.dll 无法引用 SQLite.interop.dll - Unable to reference SQLite.interop.dll 无法加载DLL&#39;SQLite.Interop.dll&#39; - 在构建时删除DLL - Unable to load DLL 'SQLite.Interop.dll' - Dll being removed on build SQlite using语句给出了无法在另一台计算机上加载DLL&#39;SQLite.Interop.dll&#39;错误 - SQlite using statement gives Unable to load DLL 'SQLite.Interop.dll' error on another computer 无法加载DLL&#39;SQLite.Interop.dll&#39;:找不到指定的模块。 Windows Server 2012上的错误 - Unable to load DLL 'SQLite.Interop.dll': The specified module could not be found. Error on Windows Server 2012 尽管出现错误“无法加载DLL&#39;SQLite.Interop.dll&#39;”,尽管它位于bin文件夹中 - Getting error “Unable to load DLL 'SQLite.Interop.dll'” despite it being in the bin folder SQLite.Interop.dll参考 - SQLite.Interop.dll reference
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM