无法在 Linux 上的 Mono 下将 SQLite 设置为 运行
Trouble getting SQLite to run under Mono on Linux
我是 C# 的初学者,我遇到了麻烦 运行 这个 SQLite+Dapper 演示:
https://github.com/mercury2269/SQLiteDemo
当 运行:
时出现以下错误
System.DllNotFoundException: System.Data.SQLite.dll
这些文件位于同一目录以及 x86 和 x64 文件夹下。我在 运行 下 Linux 使用 Mono。
现在不知道去哪里找,所以如果你们需要任何其他信息,尽管问!
更新:
必须将 Mono.Data.Sqlite 包添加到项目并将文件 Data\SqLiteBaseRepository.cs 更改为以下内容:
using System;
using Mono.Data.Sqlite;
namespace SQLiteDemo.Data
{
public class SqLiteBaseRepository
{
public static string DbFile
{
get { return Environment.CurrentDirectory + "/SimpleDb.sqlite"; }
}
public static SqliteConnection SimpleDbConnection()
{
return new SqliteConnection("Data Source=" + DbFile);
}
}
}
如果您明确针对 Mono,则使用 SQLite 连接器的 Mono 版本(不知道他们为什么决定破坏名称空间兼容性,但他们就是这样做的)。
只需将 System.Data.SQLite
中的引用和用法替换为 Mono.Data.SQLite
我是 C# 的初学者,我遇到了麻烦 运行 这个 SQLite+Dapper 演示: https://github.com/mercury2269/SQLiteDemo
当 运行:
时出现以下错误System.DllNotFoundException: System.Data.SQLite.dll
这些文件位于同一目录以及 x86 和 x64 文件夹下。我在 运行 下 Linux 使用 Mono。
现在不知道去哪里找,所以如果你们需要任何其他信息,尽管问!
更新:
必须将 Mono.Data.Sqlite 包添加到项目并将文件 Data\SqLiteBaseRepository.cs 更改为以下内容:
using System;
using Mono.Data.Sqlite;
namespace SQLiteDemo.Data
{
public class SqLiteBaseRepository
{
public static string DbFile
{
get { return Environment.CurrentDirectory + "/SimpleDb.sqlite"; }
}
public static SqliteConnection SimpleDbConnection()
{
return new SqliteConnection("Data Source=" + DbFile);
}
}
}
如果您明确针对 Mono,则使用 SQLite 连接器的 Mono 版本(不知道他们为什么决定破坏名称空间兼容性,但他们就是这样做的)。
只需将 System.Data.SQLite
中的引用和用法替换为 Mono.Data.SQLite