DllNotFoundException for SQLite.Interop.dll (C# & SQLite)

2

I'm trying to get SQLite running in Visual Studio 2012 for C#. However after going through a set of tutorials I still get the error DllNotFoundException for the SQLite.Interop.dll.

This is the full error I receive:

Unable to load DLL 'SQLite.Interop.dll': The specified path is invalid. (Exception from HRESULT: 0x800700A1)

I have created a reference for the System.Data.SQLite.dll. Now I found that I have to add the SQLite.Interop.dll file into my project folder but I still get this error.

Oh and BTW, this is my code, if anyone is interested:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SQLite;

namespace SQLiteWinFormCS
{
public partial class Form1 : Form
{

    private SQLiteConnection _sqlCon;
    private SQLiteCommand _sqlCmd;
    private SQLiteDataAdapter _db;
    private DataSet _ds = new DataSet();
    private DataTable _dt = new DataTable();
    private string _dbPath = String.Empty;

    public Form1()
    {
        InitializeComponent();
    }

    private void uiOpenDB_Click(object sender, EventArgs e)
    {
        Console(String.Format("You clicked {0}.", ((Button)sender).Name));
        this._dbPath = uiDatabaseFilepath.Text;
        Console("Filepath to DB = " + this._dbPath);

        Console("Attempting to open DB connection...");
        this._sqlCon = new SQLiteConnection(String.Format("Data Source={0};", @"\\Some-PC\ISC\Databases\testdbs\test.db3")); // << ERROR
        Console("DB connection succesfull!");

    }

    private void Console(string text)
    {
        uiConsoleOutput.AppendText(text);
        uiConsoleOutput.ScrollToCaret();
    }
}
}

Can anyone help me get this thing working?

Thanks in advance.

c#
sqlite
visual-studio-2012
asked on Stack Overflow Sep 26, 2014 by rotgers • edited Sep 26, 2014 by rotgers

2 Answers

2

Copy the SQLite.Interop.dll file into your debug folder. For example "Projects\sqlite test18\sqlite test18\bin\Debug" place it here.

And dont add the Interop as a reference.

Add only these references

  • System.Data.SQLite
  • System.Data.SQLite.EF6
  • System.Data.SQLite.EF6

This solved my problem. And I was using Sqlite x86 under x64 OS.

answered on Stack Overflow Sep 27, 2014 by Astro
1

Dohh...

I was probably using a wrong System.Data.SQLite.dll.

For anyone who is interested you can find the new .dll file I downloaded here: http://system.data.sqlite.org/index.html/doc/trunk/www/downloads.wiki

I needed the .dll for the 4.5 Framework (x86); I clicked the first download link.

Also I am using just the System.Data.SQLite.dll, no other files!

Hope this answer helps someone else. :-)

answered on Stack Overflow Sep 26, 2014 by rotgers

User contributions licensed under CC BY-SA 3.0