日期:2014-05-20  浏览次数:21146 次

无法找到 PInvoke DLL“SQLite.Interop.DLL”
        public FrmTest()
        {
            InitializeComponent();

            string dbPath = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase);

            string connecitonString = string.Format(@"Data Source={0}\AccountDB.db;password=111", dbPath);

            using (SQLiteConnection cnn=new SQLiteConnection(connecitonString))
            {
                string cmdText = "select ID,Name from ConsumptionType";
                SQLiteDataAdapter adapter = new SQLiteDataAdapter(cmdText, cnn);
                DataTable table = new DataTable("Consumption");

                try
                {
                    //每次一执行到这个话,就会出现“无法找到 PInvoke DLL“SQLite.Interop.DLL””的异常
                    adapter.Fill(table);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }

                cnn.Close();

                lstBoxConsumptionType.ValueMember = "ID";
                lstBoxConsumptionType.DisplayMember = "Name";
                lstBoxConsumptionType.DataSource = null;
                lstBoxConsumptionType.DataSource = table;
            }

                    
我看网上说是将将下载的SQLite.Interop.DLL包括到项目里,然后修改属性生成操作为“内容”复  制到输出目录为“始终复制”。http://topic.csdn.net/u/20101101/16/91e5cc8e-a52a-4a0f-bc6b-7cc044854113.html
但仍然不行。
另外,网上还说,
将你引用的SQLite的程序集System.Data.SQLite.dll的属性改为“复制到输出目录”。
但不知道怎么操作,

------解决方案--------------------
去你的sqlite 的安装目录里找 SQLite.Interop.DLL,将这个复制你的程序根目录