SQLite Error in Release Mode on Xamarin.Android

I am using sqlite-net1.0.8 in my application Xamarin.Android. It works fine in mode Debug, but when I switch to mode Release, the following lines (by default for Xamarin) in AsseblyInfo.csdisable debugging of the assembly:

#if DEBUG
[assembly: Application(Debuggable=true)]
#else
[assembly: Application(Debuggable=false)]
#endif

Because of this, many operations are SQLitenot performed due to the absence of System.Diagnostics.Debug, for example, this code:

using(var db = new SQLiteConnection(path))
    db.CreateTable<Cache>();

Throws the following exception:

[MonoDroid] System.TypeLoadException: Could not load type 'System.Diagnostics.Debug' from assembly 'MyApp'.
[MonoDroid] at SQLite.SQLiteConnection.CreateTable (System.Type,SQLite.CreateFlags) <0x002d3>
[MonoDroid] at SQLite.SQLiteConnection.CreateTable<MyApp.Cache> (SQLite.CreateFlags) <0x0002b>
[MonoDroid] at MyApp.SQLiteCache..ctor (Android.Content.Context) <0x000c3>
[MonoDroid] at MyApp.MainActivity.OnCreate (Android.OS.Bundle) <0x0008b>
[MonoDroid] at Android.App.Activity.n_OnCreate_yApp_os_Bundle_ (intptr,intptr,intptr) <0x0005b>
[MonoDroid] at (wrapper dynamic-method) object.d0784c17-eb18-447e-beb0-3e9d001bfee1 (intptr,intptr,intptr) <0x00043>

I can see the following ways of handling the situation:

  • Add a similar one #definesto sqlite-netand send pull requestsit to the author
  • Add a similar one #definesin sqlite-netand save them yourself
  • Delete #definein AssemblyInfo.csand save the debug code insqlite-net

What is the right way to handle this?

+4

All Articles