2

在我的数据库 ctor 中:

databasePath = GetPath(docsFolder);
connection = new SQLiteAsyncConnection(databasePath);
connection.CreateTableAsync<BO>().Wait();

数据库路径为 /data/user/0/com.companyname.AppName/files/fn.db3 (仅在此处过滤包名)

但是在创建表时会发生这种情况:未处理的异常:System.AggregateException:发生了一个或多个错误。

在 BO 中,我已经删除了 DateTime:目前只有 string 和 int 是应用的类型。

public class BO
{
        [PrimaryKey, AutoIncrement]
        public int ID { get; set; }

        public string From { get; set; }

        public string To { get; set; }

        public string Note { get; set; }
}

NuGet:

  <package id="sqlite-net-pcl" version="1.4.118" targetFramework="portable45-net45+win8+wpa81" />
  <package id="SQLitePCLRaw.bundle_green" version="1.1.5" targetFramework="portable45-net45+win8+wpa81" />
  <package id="SQLitePCLRaw.core" version="1.1.5" targetFramework="portable45-net45+win8+wpa81" />

编辑:在AggregateExceptionis oneTypeInitializationException中,在创建表时发生。但是在调试时 SQLite.SQLiteConnection被表示为TypeName 。在代码中明确定义。是否缺少创建 db 文件的权限?TypeInitializationExceptionSQLiteAsyncConnection connection

4

1 回答 1

0

Android 项目中缺少 2 个包。

SQLitePCLRaw.lib.e_sqlite3.android
SQLitePCLRaw.provider.e_sqlite3.android
于 2018-02-09T00:34:31.103 回答