【发布时间】:2018-02-09 08:37:48
【问题描述】:
在我的数据库管理器中:
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" />
编辑:
在AggregateException 中是一个TypeInitializationException,它在创建表时发生。但是SQLite.SQLiteConnection在调试时被声明为关于TypeInitializationException的TypeName。
SQLiteAsyncConnection connection 已在代码中明确定义。
是否缺少创建 db 文件的权限?
【问题讨论】:
-
AggregateException 不提供信息。尝试抓住它并打印它的 e.Flatten().InnerExceptions。或者只是在调试器中停止并检查内部异常。你应该得到实际的错误。
-
帖子已编辑。发生 TypeInitializationException。
-
能否请您发布整个异常消息?
-
在查看 AggregateException 条目时,调试器仅在一个条目中引用名称 (TypeInitializationException ) 和类型 (SQLite.SQLiteConnection)。调试器中不显示任何消息。我会检查是否可以打印。
-
大达。 'SQLite.SQLiteConnection' 的类型初始化程序引发了异常。这真的很有帮助。是不是。