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

发布于 2024-07-14 06:17:11 字数 445 浏览 6 评论 0原文

我正在尝试引用位​​于应用程序路径中的 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”,或者找不到指定的文件。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

万水千山粽是情ミ 2024-07-21 06:17:11

我们在工作中一般添加参考文献的方式如下:

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

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
小…红帽 2024-07-21 06:17:11

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

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文