1

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();

    }
}
Mishu666
  • 57
  • 6

1 Answers1

0

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.

Stephen McGowan
  • 69
  • 2
  • 13
  • The problem isn't within the dll, but in its inclusion in the project. I can't find it so I can't include it in my project. Am I even supposed to inclue it manually after I've included the data provider? also, it's a web forms project, there is no .csproj file, not that I can find anyway. – Mishu666 Apr 21 '19 at 12:16
  • When IIS is running the website is the DLL copied to the `Temporary ASP.NET files ` folder? I've seen some people saying they've had to copy it manually after starting IIS? – Stephen McGowan Apr 21 '19 at 12:22
  • Where can I find this folder? – Mishu666 Apr 21 '19 at 12:33
  • try here `C:\Windows\Microsoft.NET\Framework\Vx.x.xxxx\Temporary ASP.NET Files\root` – Stephen McGowan Apr 21 '19 at 12:35
  • I'm sorry I don't know much more than this. Perhaps look into that. – Stephen McGowan Apr 21 '19 at 12:40
  • okay I managed to find the x64 and x86 files in `PROJECT_FOLDER\packages\System.Data.SQLite.Core.1.0.*.*\build\net40` and it has the interop dlls. so why can't the website see them? – Mishu666 Apr 21 '19 at 12:40
  • At a pure guess, copy that into the temp files when IIS is running, and see what happens? – Stephen McGowan Apr 21 '19 at 12:46