After adding SQLCipher implementation, Xamarin iOS app crashes (due to trial warning message)


#1

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>();
         ...
        }
}

#2

Hi @Tyler_Kelly

The trial does include displaying a warning message when the library is initialized. The trial package includes a demo application that does not crash when run on iOS, can you give that demo application a try? Thanks


#3

I downloaded the SQLCipher component through Xamarin’s builtin component store so I’m not sure where the demo app is.


#4

Hi @Tyler_Kelly

When you view the component within Xamarin Studio, there is a Samples tab that allows you to open the included sample:


#5

Thanks for the info. The demo works perfectly


#6

I guess I should ask is if there are any similar messages or UI invocations that come along with the licensed version? The trial message seems to be only hold up as SQLCipher is working fine with Android.


#7

Hi @Tyler_Kelly

The trial message is present within the SQLCipher for Xamarin Android as well, it is displayed within the notification center. Those are the only trial builds available for the Xamarin platform.


#8

Yeah I realize the message is present in Android as well, but with Android you can invoke UI operations on different threads I believe which don’t cause the crash.


#9

We do not see the crash with the demo application on iOS either, do you?


#10

no I do not see the crash on the demo


#11

Hi @Tyler_Kelly,

I’m glad to hear that is working well.