vb net Unable to load DLL 'SQLite.Interop.dll

0

I am working on a Windows 7 64 bit computer with VS 2019 ver 16.7.5 and Net.Framwork ver 4.8.03761
I am getting this error
System.DllNotFoundException: Unable to load DLL 'SQLite.Interop.dll': The specified module could not
be found. (Exception from HRESULT: 0x8007007E)
at System.Data.SQLite.UnsafeNativeMethods.sqlite3_config_none(SQLiteConfigOpsEnum op)
at System.Data.SQLite.SQLite3.StaticIsInitialized()
at System.Data.SQLite.SQLiteLog.Initialize(String className)
at System.Data.SQLite.SQLiteConnection..ctor(String connectionString, Boolean parseViaFramework)
at System.Data.SQLite.SQLiteConnection..ctor(String connectionString)

I am using the same code to create a DB and DB Table that I used in a project a few months ago
It still works as expected the DB and DB Table are created
I started a New Project and coped and pasted the code to create the DB and DB Table from the older Project NOW I HAVE this ERROR which makes no sense to me. I am not trying to package the app
I am using PackageReference and do not see ApplicationEvents.vb folder in the new Project
It is present in the older project

I am not sure what is broken or how to FIX this issue
I have seen some other SO Posts but these deal with Packaging the app in an EXE file

Here is the code

Imports System.Data.SQLite

Public Class frmStart
    Public connStr As String = "Data Source={0};Version=3;"
    Public conn As SQLiteConnection

    Private Sub frmStart_Load(sender As Object, e As EventArgs) Handles MyBase.Load

        Icon = Icon.ExtractAssociatedIcon(Application.ExecutablePath)
        connStr = String.Format(connStr, gv_dbName)

        If My.Computer.FileSystem.FileExists(gv_dbName) Then
            frmMenu.Show()
            Close()
        ElseIf Not My.Computer.FileSystem.FileExists(gv_dbName) Then
            tbMessage.Text = "Create Database & Table"
        End If
    End Sub

    Private Sub btnCreate_Click(sender As Object, e As EventArgs) Handles btnCreate.Click
        makeDB()
    End Sub
    Public Sub makeDB()

        If Not My.Computer.FileSystem.FileExists(gv_dbName) Then
            Try
                conn = New SQLiteConnection($"Data Source = '{gv_dbName}';Version=3;")
                conn.Open()
                makeLabelTable()

            Catch ex As Exception
                'tbMessage.Text = "Database NOT Created"
                tbMessage.Text = ex.ToString

            End Try
            conn.Close()
            'ERROR is thrown in line of code above
            '=====================================
        End If

    End Sub
    Public Sub makeLabelTable()

        'create table LabelTable String for cmd
        Dim create_table As String = String.Empty
        create_table = "CREATE TABLE IF NOT EXISTS LabelTable(
                        TID INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
                        tFname NVARCHAR(50),
                        tLname NVARCHAR(50),
                        tAddress NVARCHAR(50),
                        tCity NVARCHAR(50),
                        tState NVARCHAR(50),
                        tZip NVARCHAR(50),
                        tFontSize NVARCHAR (500))"

        Dim dbTable As String = "LabelTable"

        If Not My.Computer.FileSystem.FileExists(dbTable) Then
            Try
                Using conn As New SQLiteConnection(connStr)
                    conn.Open()
                    Using cmd As New SQLiteCommand(create_table, conn)
                        cmd.ExecuteNonQuery()
                    End Using
                End Using
                conn.Close()
                frmMenu.Show()
                Close()
            Catch ex As Exception
                tbMessage.Text = "Label Table FAILED"
            End Try
        End If

    End Sub

This is an EDIT with a very useless SOLUTION
I copied the x86 and x64 files from the older project and pasted into the
new NON FUNCTIONING project so now it finds the Interop.dll
But this makes the Question
Why do I need to copy and paste these file to the project?
If they are needed they should get added automatically
I did not copy and paste these files in the older project what changed?
How do you add these files without doing a copy and paste ? Here is a Screen Shot FWIW
Screen Shot

vb.net
sqlite
asked on Stack Overflow Oct 25, 2020 by Vector • edited Oct 25, 2020 by Vector

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0