在应用程序路径中引用程序集

时间:2009-02-19 01:55:52

标签: ironpython system.data.sqlite assembly-reference-path

我正在尝试引用位​​于应用程序路径中的System.Data.SQLite,以便我可以将其与应用程序打包在一起。我尝试了几种不同的方式,包括:

#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")

每次它都会给我一个错误:“无法加载程序集System.Data.SQLite”或者它无法找到指定的文件。

2 个答案:

答案 0 :(得分:2)

我们通常在工作中添加引用的方式如下:

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

答案 1 :(得分:1)

确保sqlite3.dll在您的路径中,或者您使用的是嵌入了sqlite3.dll的S.D.SQLite版本。