Visual Studio C#-找不到SQLite.Interop.dll [英] Visual Studio C# - SQLite.Interop.dll not found

查看:95
本文介绍了Visual Studio C#-找不到SQLite.Interop.dll的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在尝试使用Visual Studio创建一个使用SQLite的C#应用​​程序。我使用NuGet为程序安装了SQLite,并且在解决方案资源管理器中出现了三个引用(System.Data.SQLite,System.Data.SQLite.EF6,System.Data.SQLite.Linq)。

I am currently trying to create with Visual Studio a C# application working with SQLite. I installed SQLite for my program with NuGet and three references appeared in the Solution Explorer (System.Data.SQLite, System.Data.SQLite.EF6, System.Data.SQLite.Linq).

当我在VS中执行我的应用程序时,一切正常。但是,每当我发布它(使用ClickOnce)并尝试运行该应用程序时,它都会因以下错误而崩溃:
System.DllNotFoundException:无法加载DLL'SQLite.Interop.dll':指定的模块找不到(来自HRESULT的异常:0x8007007E)

When I execute my app in VS, everything works fine. However, whenever I publish it (with ClickOnce) and try to run the app, it crashes with the following error : System.DllNotFoundException : Unable to load DLL 'SQLite.Interop.dll' : the specified module cannot be found (Exception from HRESULT : 0x8007007E)

经过一番研究,我在Debug文件夹中找到了该dll,并将其复制到了 .exe文件夹中。创建我的程序的版本(在发布并执行 setup.exe之后)。这样,应用程序运行良好。

After some research, I found this dll in the Debug folder and copied it in the folder where the ".exe" version of my program is created (after publishing and executing "setup.exe"). This way, the app runs well.

但是我对这种解决方案并不满意,因为它看起来确实很脏。我不希望将来的用户在安装我的应用程序时必须手动执行此操作!

But I'm not really satisfied with this solution, since it seems really dirty. I don't want future users to have to do this manually when they install my app !

因此,我的问题是:我该怎么做才能确保此dll与我的程序?

Therefore, my question is : What can I do to make sure that this dll is installed together with my program ?

注意:我尝试了该帖子的第一个答案:
无法加载dll sqlite interop dll WPF
但我似乎没有为我工作。

推荐答案

请参见使用本机库预加载,网址为 https://system.data.sqlite.org/index.html/doc/trunk/www/downloads.wiki

您可能需要将x86和x64文件夹包括在另一个SQLite DLL下。

You likely need to include the x86 and x64 folders under the the other SQLite DLL.

编辑:如果上述链接消失或更改,我在下面添加了相关信息。

I've added the relevant info below in case the above link ever dies/changes.


如果开发客户计算机可能具有不同的处理器架构,可能需要多个二进制软件包。对于这种
的情况,强烈建议使用本机库预加载功能。它从1.0.80.0版本开始可用,并由
默认启用。为了利用此功能,必须将单独的
受管和互操作程序集与XCOPY部署
一起使用(即,混合模式程序集不支持此功能,当程序集部署到全局程序集缓存中),在应用程序部署中产生
,如下所示:

If the development and customer machines may have different processor architectures, more than one binary package may be required. For this situation, using the native library pre-loading feature is highly recommended. It is available as of version 1.0.80.0 and enabled by default. In order to take advantage of this feature, the separate managed and interop assemblies must be used with XCOPY deployment (i.e. this feature is not supported by the mixed-mode assembly, nor when the assembly is deployed to the global assembly cache), resulting in an application deployment that looks something like this:




  • bin\App.exe(可选的,仅托管应用程序的可执行文件
    程序集)

  • bin\App.dll(可选的,仅托管应用程序的库
    程序集)

  • bin\System.Data.SQLite.dll(必需的,仅托管的核心
    程序集)

  • bin\System.Data.SQLite.Linq.dll(可选,仅托管
    LINQ程序集)

  • bin\System.Data.SQLite.EF6.dll(可选的
    仅托管EF6程序集)

  • bin\x86\SQLite.Interop.dll(必填,
    x86本机互操作程序集)

  • bin\x64\SQLite.Interop.dll(必需,
    x64本机互操作程序集)

    • bin\App.exe (optional, managed-only application executable assembly)
    • bin\App.dll (optional, managed-only application library assembly)
    • bin\System.Data.SQLite.dll (required, managed-only core assembly)
    • bin\System.Data.SQLite.Linq.dll (optional, managed-only LINQ assembly)
    • bin\System.Data.SQLite.EF6.dll (optional, managed-only EF6 assembly)
    • bin\x86\SQLite.Interop.dll (required, x86 native interop assembly)
    • bin\x64\SQLite.Interop.dll (required, x64 native interop assembly)

    • 上面的字符串 bin表示应用程序
      二进制文件所在的目录部署在目标计算机上。启用本机
      库预加载功能并且如上所示显示了应用程序部署
      之后,System.Data.SQLite仅托管程序集将尝试
      自动检测当前$ b的处理器体系结构b $ b处理并预加载适当的本机库。

      The string "bin" above represents the directory where the application binaries are to be deployed on the target machine. With the native library pre-loading feature enabled and the application deployment shown above, the System.Data.SQLite managed-only assembly will attempt to automatically detect the processor architecture of the current process and pre-load the appropriate native library.

      这篇关于Visual Studio C#-找不到SQLite.Interop.dll的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆