Database disk image is malformed in MonoTouch

2019-04-10 16:56发布

问题:

I am using Monotouch 5 to develop a multithreaded messaging application. After some days of operation, some customers receive the error Database disk image is malformed. I am using the SQLite.cs from Kueger Systems I found in the internet to access the SQLite database.

It appears there is an issue woth multiple threads accessing the database (which happens a lot). I have read somewhere about an option how the database is compiled (Single thread, multi thread, serialized). Do I specify that somehow?

I want to continue updating the database from background threads, without corrupting it. What am I doing wrong?

回答1:

You can tell sqlite how to deal with multithreading. The trick is to do it very early in your application (because once sqlite is initialized it will be too late to change it).

For SQLite.cs you can do this using this code.

In Mono.Data.Sqlite.dll you can call Mono.Data.Sqlite.SqliteConnection.SetConfig (Mono.Data.Sqlite.SQLiteConfig.*); to do the same.

In both case the valid values (for the config enum) are documented here.