【发布时间】:2019-02-01 13:15:43
【问题描述】:
我正在使用 SQLite-net-PCL nugget 我无法使用此模型创建表。我在这里遇到了这个异常。
内部异常条件:
at SQLite.SQLite3.Prepare2 (SQLitePCL.sqlite3 db, System.String query) [0x0001b] in <eaa146ee868043e287f5507c8701ad9e>:0
02-01 18:18:23.620 I/mono-stdout( 3072): at SQLite.SQLite3.Prepare2 (SQLitePCL.sqlite3 db, System.String query) [0x0001b] in <eaa146ee868043e287f5507c8701ad9e>:0
at SQLite.SQLiteCommand.Prepare () [0x00011] in <eaa146ee868043e287f5507c8701ad9e>:0
02-01 18:18:23.625 I/mono-stdout( 3072): at SQLite.SQLiteCommand.Prepare () [0x00011] in <eaa146ee868043e287f5507c8701ad9e>:0
at SQLite.SQLiteCommand.ExecuteNonQuery () [0x00030] in <eaa146ee868043e287f5507c8701ad9e>:0
02-01 18:18:23.627 I/mono-stdout( 3072): at SQLite.SQLiteCommand.ExecuteNonQuery () [0x00030] in <eaa146ee868043e287f5507c8701ad9e>:0
at SQLite.SQLiteConnection.Execute (System.String query, System.Object[] args) [0x00039] in <eaa146ee868043e287f5507c8701ad9e>:0
02-01 18:18:23.629 I/mono-stdout( 3072): at SQLite.SQLiteConnection.Execute (System.String query, System.Object[] args) [0x00039] in <eaa146ee868043e287f5507c8701ad9e>:0
at SQLite.SQLiteConnection.MigrateTable (SQLite.TableMapping map, System.Collections.Generic.List`1[T] existingCols) [0x000ae] in <eaa146ee868043e287f5507c8701ad9e>:0
02-01 18:18:23.631 I/mono-stdout( 3072): at SQLite.SQLiteConnection.MigrateTable (SQLite.TableMapping map, System.Collections.Generic.List`1[T] existingCols) [0x000ae] in <eaa146ee868043e287f5507c8701ad9e>:0
at SQLite.SQLiteConnection.CreateTable (System.Type ty, SQLite.CreateFlags createFlags) [0x0013e] in <eaa146ee868043e287f5507c8701ad9e>:0
02-01 18:18:23.632 I/mono-stdout( 3072): at SQLite.SQLiteConnection.CreateTable (System.Type ty, SQLite.CreateFlags createFlags) [0x0013e] in <eaa146ee868043e287f5507c8701ad9e>:0
at SQLite.SQLiteConnection.CreateTable[T] (SQLite.CreateFlags createFlags) [0x00000] in <eaa146ee868043e287f5507c8701ad9e>:0
02-01 18:18:23.634 I/mono-stdout( 3072): at SQLite.SQLiteConnection.CreateTable[T] (SQLite.CreateFlags createFlags) [0x00000] in <eaa146ee868043e287f5507c8701ad9e>:0
at SQLite.SQLiteAsyncConnection+<>c__DisplayClass31_0`1[T].<CreateTableAsync>b__0 (SQLite.SQLiteConnectionWithLock conn) [0x00000] in <eaa146ee868043e287f5507c8701ad9e>:0
02-01 18:18:23.636 I/mono-stdout( 3072): at SQLite.SQLiteAsyncConnection+<>c__DisplayClass31_0`1[T].<CreateTableAsync>b__0 (SQLite.SQLiteConnectionWithLock conn) [0x00000] in <eaa146ee868043e287f5507c8701ad9e>:0
at SQLite.SQLiteAsyncConnection+<>c__DisplayClass29_0`1[T].<WriteAsync>b__0 () [0x00013] in <eaa146ee868043e287f5507c8701ad9e>:0
02-01 18:18:23.638 I/mono-stdout( 3072): at SQLite.SQLiteAsyncConnection+<>c__DisplayClass29_0`1[T].<WriteAsync>b__0 () [0x00013] in <eaa146ee868043e287f5507c8701ad9e>:0
at System.Threading.Tasks.Task`1[TResult].InnerInvoke () [0x0000f] in <d4a23bbd2f544c30a48c44dd622ce09f>:0
02-01 18:18:23.640 I/mono-stdout( 3072): at System.Threading.Tasks.Task`1[TResult].InnerInvoke () [0x0000f] in <d4a23bbd2f544c30a48c44dd622ce09f>:0
at System.Threading.Tasks.Task.Execute () [0x00000] in <d4a23bbd2f544c30a48c44dd622ce09f>:0 02-01 18:18:23.641 I/mono-
public class Setting
{
[PrimaryKey]
// public int id { get; set; }
public int UserID { get; set; }
public string Email { get; set; }
public bool AutoUpload { get; set; }
public bool UseCellularData { get; set; }
public int MaxStoredRecordings { get; set; }
public string UnitPreference { get; set; }
public string DateFormatPreference { get; set; }
public string TimeFormat { get; set; }
public string SerialNo { get; set; }
}
实际例外:
我遇到了这个异常
System.AggregateException: One or more errors occurred.D/ConnectivityManager.CallbackHandler( 487): CM callback handler got msg 524294
02-01 19:06:50.907 I/mono-stdout( 487): at System.Threading.Tasks.Task.ThrowIfExceptional (System.Boolean includeTaskCanceledExceptions) [0x00011] in <d4a23bbd2f544c30a48c44dd622ce09f>:0
at System.Threading.Tasks.Task.ThrowIfExceptional (System.Boolean includeTaskCanceledExceptions) [0x00011] in <d4a23bbd2f544c30a48c44dd622ce09f>:0
at System.Threading.Tasks.Task.Wait (System.Int32 millisecondsTimeout, System.Threading.CancellationToken cancellationToken) [0x00043] in <d4a23bbd2f544c30a48c44dd622ce09f>:0 02-01 19:06:50.917 I/mono-stdout( 487): at System.Threading.Tasks.Task.Wait (System.Int32 millisecondsTimeout, System.Threading.CancellationToken cancellationToken) [0x00043] in <d4a23bbd2f544c30a48c44dd622ce09f>:0 at System.Threading.Tasks.Task.Wait () [0x00000] in <d4a23bbd2f544c30a48c44dd622ce09f>:0
02-01 19:06:50.919 I/mono-stdout( 487): at System.Threading.Tasks.Task.Wait () [0x00000] in <d4a23bbd2f544c30a48c44dd622ce09f>:0
at Feelix.Storage.DatabaseManager..ctor (System.String dbPath) [0x0003c] in D:\22\developer branch\Feelix\Feelix\Feelix\Storage\DatabaseManager.cs:45
02-01 19:06:50.921 I/mono-stdout( 487): at Feelix.Storage.DatabaseManager..ctor (System.String dbPath) [0x0003c] in D:\22\developer branch\Feelix\Feelix\Feelix\Storage\DatabaseManager.cs:45
Thread finished: <Thread Pool> #2
The thread 0x2 has exited with code 0 (0x0).
我的桌子
database = new SQLiteAsyncConnection(dbPath);
database.CreateTableAsync<Patient>().Wait();
database.CreateTableAsync<User>().Wait()
database.CreateTableAsync<Setting>().Wait();
database.CreateTableAsync<DeviceSessionDB>().Wait();
database.CreateTableAsync<DeviceSessionRecordingsDB>().Wait();
除设置页表外,所有表均创建成功。
【问题讨论】:
-
您是否要更改现有表?
-
你能显示实际的异常信息和代码吗?
-
不,我不会改变这张桌子@SushiHangover
-
嗨@Crowcoder,我遇到了这个异常
-
在您的
catch块中 flatten the aggregate exception 并使用异常消息更新问题。
标签: c# sqlite xamarin xamarin.forms