zoukankan      html  css  js  c++  java
  • C#使用SQLite出错:无法加载 DLL“SQLite.Interop.dll”,找不到指定的模块

    引用:https://www.mzwu.com/article.asp?id=3180

    在SQLite官方下载了System.Data.SQLite,编写如下测试代码:
    复制内容到剪贴板程序代码
    using (SQLiteConnection conn = new SQLiteConnection(@"Data Source=F:my.db;Pooling=true;FailIfMissing=false"))
    {
    using (SQLiteDataAdapter adapter = new SQLiteDataAdapter("select id,total from table1", conn))
    {
    DataTable table1 = new DataTable();
    adapter.Fill(table1);

    MessageBox.Show(table1.Rows[0]["total"].ToString());
    }
    }

    运行出错,在new SQLiteConnection处提示:
    引用内容
    无法加载 DLL“SQLite.Interop.dll”: 找不到指定的模块。 (异常来自 HRESULT:0x8007007E)。


    解决方法

    我下载的System.Data.SQLite版本是Precompiled Binaries for 32-bit Windows (.NET Framework 3.5 SP1),这个版本提供了两个zip包:

    ①.sqlite-netFx35-binary-bundle-Win32-2008-1.0.79.0.zip
    引用内容
    This binary package features the mixed-mode assembly and contains all the binaries for the x86 version of the System.Data.SQLite 1.0.79.0 (3.7.10) package. The Visual C++ 2008 SP1 runtime for x86 and the .NET Framework 3.5 SP1 are required.

    ②.sqlite-netFx35-binary-Win32-2008-1.0.79.0.zip
    引用内容
    This binary package contains all the binaries for the x86 version of the System.Data.SQLite 1.0.79.0 (3.7.10) package. The Visual C++ 2008 SP1 runtime for x86 and the .NET Framework 3.5 SP1 are required.

    带bundle的表示动态库是按混合模式编译的,在使用的时候只需要System.Data.SQLite.dll就可以了,而不带bundle的则是将非托管部分和托管部分分别编译,System.Data.SQLite.dll不能独立使用,还需要有SQLite.Interop.dll才能使用。

    我用的是不带bundle包中的System.Data.SQLite.dll,解决方法是要么手工复制SQLite.Interop.dll和exe放一块(不能用引用),要么换成引用bundle包中的System.Data.SQLite.dll。

    相关链接

    [1]·System.Data.SQLite Download Page:http://system.data.sqlite.org/index.html/doc/trunk/www/downloads.wiki

  • 相关阅读:
    中标麒麟QT5编译出现:cannot find -lGL 和 collect2:error:ld returned 1 exit status 错误
    虚拟机设置静态ip【实测中标麒麟】
    selenium webdriver如何拿到页面的加载时间
    有感于去哪儿的一道笔试题
    python selenium 常见问题列表
    乙醇的webdriver实用指南java版本
    乙醇的webdriver实用指南ruby版本
    作死的自动化测试
    从龙门镖局看自动化测试
    无用的自动化测试
  • 原文地址:https://www.cnblogs.com/rickyliu/p/13098868.html
Copyright © 2011-2022 走看看