首页 文章

为什么在将LINite Nuget Package添加到LINQPad时会出现DllNotFoundException?

提问于
浏览
6

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

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

但我得到:

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

如何判断LINQPad在哪里可以找到SQLite Native DLL?

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

2 回答

  • 3

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

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

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

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

  • 9

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

    • 在某处复制System.Data.SQLite.dll文件(也可能还有相应的System.Data.SQLite.xml文件),例如与LINQPad查询文件位于同一目录中 .

    • 复制x64和x86子目录,例如从目录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]中复制文件的同一目录 .

    • 将以下代码添加到LINQPad查询中:

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

    这相对于Joe Albahari(LINQPad by the the way!的创建者)提交的答案的优点是,这可以很容易地包含在Git仓库中(如果你要存储你的LINQPad查询) .

相关问题