1

I am trying to reference System.Data.SQLite which is located in the application path so that I can package it with the application. I have tried several different ways including:

#1
clr.AddReferenceToFile("System.Data.SQLite.DLL")

#2
clr.AddReferenceToFileAndPath("C:\\Path\\To\\System.Data.SQLite.DLL")

#3
sys.path.append(os.getcwd())
clr.AddReferenceToFile("System.Data.SQLite.DLL")

Each time it will either give me an error: "Could not load assembly System.Data.SQLite" or that it can't find the specified file.

Simon Hartcher
  • 3,400
  • 3
  • 30
  • 34

2 Answers2

2

The way we generally add references at work is the following:

import sys
import clr
# forward slashes work fine here and don't need to be escaped
sys.path.append('c:/path/to/directory/containing/dll')
clr.AddReference('System.Data.SQLite') # note lack of .dll
babbageclunk
  • 8,523
  • 1
  • 33
  • 37
1

Make sure that sqlite3.dll is in your path, or that you are using the version of the S.D.SQLite that has the sqlite3.dll embedded in it.

maxwellb
  • 13,366
  • 2
  • 25
  • 35