First, thank you for the library. It is helping us a great deal in our WP7 project. There are some issues we hope you can help look at.
1. Currently, we face a problem which occasionally occurs when the app is opened. An exception is thrown when the database is opened. The stack trace reveals the Database.LoadTable() method (invoked during Database.OpenDatabase) as the
original place where the exception is thrown.
internal void LoadTable(IsolatedStorageFileStream tableStream, Type tableType)
using (StreamReader reader = new StreamReader(tableStream))
content = reader.ReadToEnd(); // content is null
content = Cryptography.Decrypt(content, _password);
using (StringReader stringReader = new StringReader(content))
XmlSerializer serializer = new XmlSerializer(tableType);
ITable table = (ITable)serializer.Deserialize(stringReader); // exception here
List<ITable> tables = new List<ITable>(_tables);
var tableToRemove = (from oneTable in tables
where oneTable.RowType == table.RowType
_tables = new ReadOnlyCollection<ITable>(tables);
For some reason, the content variable is an empty string ("", not null) and that leads to the XmlSerializer to throw exception when the Deserialize(stringReader) is invoked. We confirm that we call OpenDatabase()
after making sure the database exists by calling DoesDatabaseExist() method. Besides, when we create the database for the first time, we did invoke all the necessary Database.CreateTable<T>() method to setup all tables.
2. We apply the singleton pattern for the database, that is we open the database once (during application launching/activation) and keep it as a static field in the app. When the app is closed/activated (or when there's an unhandled exception),
we would invoke Database.Save(). We hope to improve the app performance and at the same time avoid unnecessary IsolatedStorage transactions, which could be a source of potential errors. Do you think this is a good/correct use of the library? Is
there any chance this is the cause of #1?
Thanks again for the library and we look forwards to hearing from you.