I recently added the trial version of SQLCipher to my project. It works perfectly for Android but when I went to use a similar implementation for the iOS version of the app, I get a run time error at start up with the error message:
System.TypeInitializationException: The type initializer for 'project_name.DAL.Repository' threw an exception. ---> System.NullReferenceException: Object reference not set to an instance of an object
at Mono.Data.Sqlcipher.TrialWarning.ShowWarning (System.String message) [0x0001d] in <filename unknown>:0
at SQLite.Net.Platform.SQLCipher.XamarinIOS.SQLitePlatformIOS..ctor (System.String key) [0x00006] in <filename unknown>:0
at eOMIS.DL.Database..ctor (System.String path) [0x00006] in /Users/tkelly/Projects/svn/NativeApps/Xamarin/PandP/Android_iOS/project_name/DataLayer/Database.cs:46
at project_name.DAL.Repository..ctor () [0x0001e] in /Users/tkelly/Projects/svn/NativeApps/Xamarin/PandP/Android_iOS/project_name/DataAccessLayer/Repository.cs:26
at project_name.DAL.Repository..cctor () [0x00001] in /Users/tkelly/Projects/svn/NativeApps/Xamarin/PandP/Android_iOS/project_name/DataAccessLayer/Repository.cs:17
I have reasoned that the issue is due to the trial warning message being invoked from a different thread then the Main UIThread causing a deadlock. How can I solve this problem? I am in a bit of a deadlock myself as I want the product, but I need to test it out first, and I can’t successfully try it out first if I don’t have the licensed product.
Is there anyway to suppress this message on the phone? I do not want to try and add asynchronous code all throughout my project to fix this if it will just be taken out once the trial message is gone when I have the official product but until then, what can I do? Thanks for any help.
EDIT: to be a bit more specific I use this to establish a SQLiteConnection
:
public class Database: SQLiteConnection{
public Database (string path) : base (new SQLite.Net.Platform.SQLCipher.XamarinIOS.SQLitePlatformIOS("password"), path, true, null){
CreateTable<Field>();
...
}
}