这是我为数据库连接编写的代码:
private static void OnTimedEvent(Object source, ElapsedEventArgs e)
{
using (SQLiteConnection con = new SQLiteConnection(connectionString))
{
try
{
con.Open();
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
if (con.State == System.Data.ConnectionState.Open)
{
Console.WriteLine("Database Opened");
ushort[] writeData = new ushort[10];
writeData = parseList(byteList);
if (writeData != errorBytes)
{
writeToDb(con, writeData);
}
else
{
Console.WriteLine("Error Bytes returned! BROKEN DATA!!!");
}
//con.Close();
}
else
{
Console.WriteLine("Can't open the database!");
}
}
}`
当我在我编写代码的计算机上运行该程序时,它可以正常工作并打开数据库。但是,当我在另一台计算机上运行我的程序时,代码不会进入 using
语句并给出异常 SQLite.Interop.dll
not found。我将 System.Data.SQLite.dll
添加到我的项目引用中。我在另一台计算机上也有这个 dll 文件。我是否需要向另一台计算机添加任何内容才能使该程序正常运行?
最佳答案
我发现问题出在 SQLite dll 上。当我从 NuGet 包管理器安装 System.Data.SQLite 库并将平台目标设置为 x86 时,问题已解决。虽然在我问这个问题之前平台目标是 x86,但是从 NuGet 包管理器重新安装库解决了我的问题。在此之前,我使用的是从 http://system.data.sqlite.org/index.html/doc/trunk/www/downloads.wiki 下载的 dll。作为我项目的引用。
关于c# - SQlite using 语句在另一台计算机上给出无法加载 DLL 'SQLite.Interop.dll' 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29764189/