1
votes

I want to connect an asp.net web forms project to a sqlite database so I created a Dbase.cs class to handle sql commands. after including the System.Data.SQLite provider with Nuget I get thefollowing error - Unable to load DLL 'SQLite.Interop.dll': The specified module could not be found.

I read that I need to specify the correct architecture (x64/x86) but I cannot seem to find the SQLite.Interop.dll file anywhere. Do I need to install something other than the binary bundle for my platform?

Dbase.cs:

using System;
using System.Data;
using System.Web;
using System.Data.SQLite;

public class Dbase
{
    public Dbase()
    {

    }

    public static SQLiteConnection MakeConnection(string dbFile = "DB.sqlite")
    {
        SQLiteConnection c = new SQLiteConnection();
        c.ConnectionString = "Data Source=" +
            HttpContext.Current.Server.MapPath("~/App_Data/" + dbFile) +
            ";Version=3;";
             c.Open();
        return c;
    }

    public static DataTable SelectFromTable(string strSQLite, string FileName = "DB.sqlite")
    {
        SQLiteConnection c = MakeConnection(FileName);
        SQLiteCommand comm = new SQLiteCommand();
        comm.CommandText = strSQLite;
        comm.Connection = c;
        DataTable dt = new DataTable();
        SQLiteDataAdapter da = new SQLiteDataAdapter(comm);
        da.Fill(dt);
        c.Close();
        return dt;
    }

    public static void ChangeTable(string strSQLite, string FileName = "DB.sqlite")
    {
        SQLiteConnection c = MakeConnection(FileName);
        SQLiteCommand comm = new SQLiteCommand();
        comm.CommandText = strSQLite;
        comm.Connection = c;
        comm.ExecuteNonQuery();
        c.Close();

    }
}
1

1 Answers

0
votes

DLLs aren't to be considered as files to be edited. They're Dynamic-linked-libraries. That is, they are the result of your other files compiled into one, and are only available after compilation.

Your problem lays elsewhere and not within the DLL. Another file has a problem in it, and it's bubbling to the surface once that file is compiled into the DLL.

Are your package references correct in your .csproj files? If so, I would suggest looking at this comment in a similar thread.