【问题标题】:Why am I getting DllNotFoundException when adding SQLite Nuget Package to LINQPad?为什么将 SQLite Nuget 包添加到 LINQPad 时出现 DllNotFoundException?
【发布时间】:2016-01-15 17:55:27
【问题描述】:

我已将System.Data.SQLite.Core NuGet 包添加到我的 LINQPad 5 查询(高级版)中,然后尝试执行以下操作:

new SQLiteConnection(":memory:").Dump();

但我明白了:

DllNotFoundException:无法加载 DLL 'SQLite.Interop.dll': 找不到指定的模块。 (HRESULT 的例外情况: 0x8007007E)

如何告诉 LINQPad 在哪里可以找到 SQLite Native DLL?

请注意我不想使用 IQ 驱动程序。

【问题讨论】:

    标签: c# .net sqlite linqpad


    【解决方案1】:

    此库未以标准方式引用,因为它是原生的,并且需要为 X86 和 X64 提供不同的图像。

    LINQPad 中的解决方法是找到以下文件夹:

    %localappdata%\LINQPad\NuGet.FW46\System.Data.SQLite.Core\System.Data.SQLite.Core.1.0.99.0\build\net46
    

    并将 X86X64 子文件夹复制到 LINQPad.exe 所在的文件夹中。

    【讨论】:

      【解决方案2】:

      基于this comment in the LINQPad forum 的另一种解决方案是执行以下操作:

      1. System.Data.SQLite.dll 文件(也可能还有相应的 System.Data.SQLite.xml 文件)复制到某处,例如与您的 LINQPad 查询文件位于同一目录中。
      2. 复制 x64x86 子目录,例如从目录 C:\Users\your-user-name-goes-here\AppData\Local\LINQPad\NuGet.FW46\System.Data.SQLite\System.Data.SQLite.Core.1.0.103\build \net46,复制到您在步骤 [1] 中复制文件的同一目录。
      3. 将以下代码添加到您的 LINQPad 查询中:

        System.Environment.SetEnvironmentVariable(
            "PreLoadSQLite_BaseDirectory",
            @"C:\path\to\which\you\copied\the\files\and\directories\in\steps\one\and\two");
        

      相对于 Joe Albahari(顺便说一下 LINQPad 的创建者!)提交的答案,其优势在于它可以很容易地包含在 Git 存储库中(如果您要存储您的 LINQPad 查询)。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2010-12-07
        • 1970-01-01
        • 2015-03-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-02-06
        相关资源
        最近更新 更多