- edited description
Exception thrown: 'SQLite.Net.SQLiteException' in SQLite.Net.Platform.WinRT.dll
The UWP Headed app targeting Raspberry Pi ARM using SQLiteNetExtentions works great!!!
However, when same code is ran as a UWP Headless solution targeting same ARM platform, a run-time exception is thrown on very first query in my code, for example:
db.Query<MixModel>("select * from MixModel") causes Exception thrown: 'SQLite.Net.SQLiteException' in SQLite.Net.Platform.WinRT.dll
Both Headed and Headless instances SQLiteConnection works fine! For example, SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), this.DbPath); So I have database connectivity for both Headed and Headless using same codebase and dependent packages.
Attachments include: Visual Studio 2015 NuGet Packages dependencies and Project Reference Manager Extension versions.
Sincerely, Michael
Comments (9)
-
reporter -
reporter - edited description
-
What error are you getting?
-
reporter Connects fine to DB but on very first query in code gives: Exception thrown: 'SQLite.Net.SQLiteException' in SQLite.Net.Platform.WinRT.dll
-
reporter using SQLite.Net; using SQLiteNetExtensions.Attributes; using SQLiteNetExtensions.Extensions; using SQLiteNetExtensions.Exceptions; using System.Diagnostics; //Class not shown for sake of clarity. Class methods are shown below... public List<MixModel> SelectAllMixModelsWithChildren() { List<MixModel> resultSet = null; using (var db = this.Connect()) { db.TraceListener = new DebugTraceListener(); try { // Guillermo, // Exception happens only when app runs "Headless" // BTW, this is the first query in my program. // 'SQLite.Net.SQLiteException' in SQLite.Net.Platform.WinRT.dll var tableQuery = db.Query<MixModel>("select * from MixModel"); resultSet = new List<MixModel>(); foreach (var row in tableQuery) { //Get Music Mix, DJ Mixer Boards and Channels for each disco var mixModel = db.GetWithChildren<MixModel>(row.Name, recursive: true); resultSet.Add(mixModel); //State what came back to help support debug of various views: Debug.WriteLine(String.Format("Found mix name {0} in DB", mixModel.Name)); Debug.WriteLine(String.Format("Found {0} boards in DB", mixModel.ADCBoardModels.Count)); } } catch (Exception ex) { Debug.WriteLine(String.Format("SCDB.SelectAllMixModels() threw exeception that was squelched: {0}", ex.Message)); } } return resultSet; } public SQLite.Net.SQLiteConnection Connect() { Debug.WriteLine("Connecting in to scdb.sqlite..."); this.DbPath = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "scdb.sqlite"); SQLite.Net.SQLiteConnection connection = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), this.DbPath); Debug.WriteLine("Connected to scdb.sqlite!"); return connection; }
-
reporter My guess is the DB file cannot be shared between two different apps. The Headed and Headless App are the same code but the Headless and Headed App get deployed in different packages to the target ARM machine.
Guillermo, contrasting with code clip above and below, using using SQLiteNetExtentions, how do you specify a shared DB file store so that multiple local apps can use same DB?
string dbPath = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "scdb.sqlite");
-
I don't know why it crashes, but as it doesn't crash in SQLite-Net Extensions code, you may have better luck asking in the sqlite-net project page. I'm afraid I cannot be much more helpful in this concern.
Kind regards.
-
reporter Understood. I simply created a new database for the second app (Headless App) and all works fine. The takeaway here is UWP apps cannot share their Windows.Storage.ApplicationData.Current.LocalFolder.Path with another app. For multiple apps requiring the same database, then this points to hosting the database in a cloud. Thank you for your patience on these details.
-
reporter - changed status to closed
- Log in to comment