简体   繁体   中英

Why does my Xamarin.Forms app crash after inserting data to a SQLite database from a web API?

My Xamarin.Forms app calls data from a web API in XML form, deserializes it with Newtonsoft.JsonConvert, and now I'm trying to get it to insert that data into a local SQLite database within the app - this is triggered by pressing a button.

The data for this particular table has two columns and seven rows, and this is stored as the class Location.cs.

Here's my code:

public MainPage()
 {
  InitializeComponent();
 } 

 public async void GetLocations()
 {
    var httpClient = new HttpClient();
    var response = await httpClient.GetStringAsync("my API url is here");
    var locations = JsonConvert.DeserializeObject<List<Location>>(response);
    SQLiteConnection conn = new SQLiteConnection(App.DatabaseLocation);
    conn.CreateTable<Location>();
    conn.Insert(locations);
    conn.Close();
 }


 private void Button_Clicked(object sender, EventArgs e)
 {
 GetLocations();

    //await Navigation.PushAsync(new LocationPage());
    //this code navigates to the next page in the app
 }

So I've put breakpoints on the last three lines within the GetLocations method, and the first two go off perfectly; QuickWatch tells me all the data has been inserted successfully into the correct format.

It's after that, presumably when I try to close the table connection that the app crashes and I get "System.ArgumentException: 'method arguments are incompatible'".

It does not hit the conn.Close(); breakpoint at all, it seems to finish the insert and then throw the exception. I don't know why this is happening - I doubt it is related to memory, as the Android emulator I test on has 4GB of RAM assigned and this table has only seven rows.

EDIT: Included sample of data from API in XML form vs. class as defined in C#.

<Location>
<Location_Desc>B1_SAMPLE LOCATION</Location_Desc>
<LocationCode>B1</LocationCode>
</Location>

And

public class Location
    {

        public string Location_Desc { get; set; }
        public string LocationCode { get; set; }
    }

EDIT 2: Included output from debugger.

09-09 14:37:40.676 D/Mono    (19158): DllImport searching in: '__Internal' ('(null)').
09-09 14:37:40.677 D/Mono    (19158): Searching for 'java_interop_jnienv_call_float_method_a'.
09-09 14:37:40.677 D/Mono    (19158): Probing 'java_interop_jnienv_call_float_method_a'.
09-09 14:37:40.677 D/Mono    (19158): Found as 'java_interop_jnienv_call_float_method_a'.
09-09 14:37:40.758 D/Mono    (19158): Loading reference 3 of APPNAME.dll asmctx DEFAULT, looking for SQLite-net, Version=1.5.231.0, Culture=neutral, PublicKeyToken=null
09-09 14:37:40.758 D/Mono    (19158): Assembly Ref addref APPNAME[0xf01626a0] -> SQLite-net[0xf01627c0]: 2
09-09 14:37:40.760 D/Mono    (19158): Loading reference 1 of System.Net.Http.dll asmctx DEFAULT, looking for System, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e
09-09 14:37:40.760 D/Mono    (19158): Assembly Ref addref System.Net.Http[0xebce8ae0] -> System[0xf016d200]: 6
09-09 14:37:40.761 D/Mono    (19158): Loading reference 5 of APPNAME.dll asmctx DEFAULT, looking for Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed
09-09 14:37:40.761 D/Mono    (19158): Assembly Ref addref APPNAME[0xf01626a0] -> Newtonsoft.Json[0xf01625e0]: 2
09-09 14:37:40.761 D/Mono    (19158): Loading reference 2 of SQLite-net.dll asmctx DEFAULT, looking for System.Collections, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
09-09 14:37:40.761 D/Mono    (19158): Image addref System.Collections[0xd0c204c0] (asmctx DEFAULT) -> System.Collections.dll[0xd2bf1200]: 2
09-09 14:37:40.761 D/Mono    (19158): Prepared to set up assembly 'System.Collections' (System.Collections.dll)
09-09 14:37:40.761 D/Mono    (19158): Assembly System.Collections[0xd0c204c0] added to domain RootDomain, ref_count=1
09-09 14:37:40.761 D/Mono    (19158): AOT: image 'System.Collections.dll.so' not found: (null)
09-09 14:37:40.761 D/Mono    (19158): AOT: image '/Users/builder/jenkins/workspace/archive-mono/2019-02/android/release/sdks/out/android-x86-release/lib/mono/aot-cache/x86/System.Collections.dll.so' not found: (null)
09-09 14:37:40.761 D/Mono    (19158): Config attempting to parse: 'System.Collections.dll.config'.
09-09 14:37:40.761 D/Mono    (19158): Config attempting to parse: '/Users/builder/jenkins/workspace/archive-mono/2019-02/android/release/sdks/out/android-x86-release/etc/mono/assemblies/System.Collections/System.Collections.config'.
09-09 14:37:40.761 D/Mono    (19158): Assembly Ref addref SQLite-net[0xf01627c0] -> System.Collections[0xd0c204c0]: 2
09-09 14:37:40.761 D/Mono    (19158): Loading reference 0 of System.Collections.dll asmctx DEFAULT, looking for mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e
09-09 14:37:40.761 D/Mono    (19158): Assembly Ref addref System.Collections[0xd0c204c0] -> mscorlib[0xf0162580]: 62
09-09 14:37:40.761 D/Mono    (19158): Loading reference 3 of SQLite-net.dll asmctx DEFAULT, looking for System.Runtime.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
09-09 14:37:40.762 D/Mono    (19158): Image addref System.Runtime.Extensions[0xd229ec80] (asmctx DEFAULT) -> System.Runtime.Extensions.dll[0xd2bf1700]: 2
09-09 14:37:40.762 D/Mono    (19158): Prepared to set up assembly 'System.Runtime.Extensions' (System.Runtime.Extensions.dll)
09-09 14:37:40.762 D/Mono    (19158): Assembly System.Runtime.Extensions[0xd229ec80] added to domain RootDomain, ref_count=1
09-09 14:37:40.762 D/Mono    (19158): AOT: image 'System.Runtime.Extensions.dll.so' not found: (null)
09-09 14:37:40.762 D/Mono    (19158): AOT: image '/Users/builder/jenkins/workspace/archive-mono/2019-02/android/release/sdks/out/android-x86-release/lib/mono/aot-cache/x86/System.Runtime.Extensions.dll.so' not found: (null)
09-09 14:37:40.762 D/Mono    (19158): Config attempting to parse: 'System.Runtime.Extensions.dll.config'.
09-09 14:37:40.762 D/Mono    (19158): Config attempting to parse: '/Users/builder/jenkins/workspace/archive-mono/2019-02/android/release/sdks/out/android-x86-release/etc/mono/assemblies/System.Runtime.Extensions/System.Runtime.Extensions.config'.Loaded assembly: System.Collections.dll [External]

09-09 14:37:40.762 D/Mono    (19158): Assembly Ref addref SQLite-net[0xf01627c0] -> System.Runtime.Extensions[0xd229ec80]: 2
09-09 14:37:40.762 D/Mono    (19158): Loading reference 1 of System.Runtime.Extensions.dll asmctx DEFAULT, looking for System, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e
09-09 14:37:40.762 D/Mono    (19158): Assembly Ref addref System.Runtime.Extensions[0xd229ec80] -> System[0xf016d200]: 7
09-09 14:37:40.762 D/Mono    (19158): Loading reference 0 of System.Runtime.Extensions.dll asmctx DEFAULT, looking for mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e
09-09 14:37:40.762 D/Mono    (19158): Assembly Ref addref System.Runtime.Extensions[0xd229ec80] -> mscorlib[0xf0162580]: 63
09-09 14:37:40.762 D/Mono    (19158): Loading reference 1 of SQLite-net.dll asmctx DEFAULT, looking for SQLitePCLRaw.core, Version=1.1.11.121, Culture=neutral, PublicKeyToken=1488e028ca7ab535
09-09 14:37:40.762 D/Mono    (19158): Assembly Ref addref SQLite-net[0xf01627c0] -> SQLitePCLRaw.core[0xf01628e0]: 2
Loaded assembly: System.Runtime.Extensions.dll [External]
09-09 14:37:40.796 D/Mono    (19158): Loading reference 1 of Mono.Android.dll asmctx DEFAULT, looking for System.Net.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
09-09 14:37:40.796 D/Mono    (19158): Assembly Ref addref Mono.Android[0xf016d0e0] -> System.Net.Http[0xebce8ae0]: 3
Thread started:  #2
09-09 14:37:41.083 D/NetworkSecurityConfig(19158): Using Network Security Config from resource network_security_config debugBuild: true
Thread started: <Thread Pool> #3
Thread started: <Thread Pool> #4
09-09 14:37:41.210 D/Mono    (19158): DllImport attempting to load: 'libmono-native.so'.
09-09 14:37:41.216 D/Mono    (19158): DllImport loaded library './libmono-native.so'.
09-09 14:37:41.216 D/Mono    (19158): DllImport searching in: 'libmono-native.so' ('./libmono-native.so').
09-09 14:37:41.216 D/Mono    (19158): Searching for 'SystemNative_GetNonCryptographicallySecureRandomBytes'.
09-09 14:37:41.216 D/Mono    (19158): Probing 'SystemNative_GetNonCryptographicallySecureRandomBytes'.
09-09 14:37:41.216 D/Mono    (19158): Found as 'SystemNative_GetNonCryptographicallySecureRandomBytes'.
Thread started: <Thread Pool> #5
Thread started: <Thread Pool> #6
09-09 14:37:41.262 I/Choreographer(19158): Skipped 30 frames!  The application may be doing too much work on its main thread.
Thread started: <Thread Pool> #7
09-09 14:37:41.884 D/Mono    (19158): DllImport searching in: '__Internal' ('(null)').
09-09 14:37:41.885 D/Mono    (19158): Searching for 'java_interop_jnienv_call_boolean_method'.
09-09 14:37:41.885 D/Mono    (19158): Probing 'java_interop_jnienv_call_boolean_method'.
09-09 14:37:41.885 D/Mono    (19158): Found as 'java_interop_jnienv_call_boolean_method'.
09-09 14:37:41.992 D/Mono    (19158): DllImport searching in: '__Internal' ('(null)').
09-09 14:37:41.992 D/Mono    (19158): Searching for 'java_interop_jnienv_new_byte_array'.
09-09 14:37:41.992 D/Mono    (19158): Probing 'java_interop_jnienv_new_byte_array'.
09-09 14:37:41.992 D/Mono    (19158): Found as 'java_interop_jnienv_new_byte_array'.
09-09 14:37:41.995 D/Mono    (19158): DllImport searching in: '__Internal' ('(null)').
09-09 14:37:41.995 D/Mono    (19158): Searching for 'java_interop_jnienv_set_byte_array_region'.
09-09 14:37:41.995 D/Mono    (19158): Probing 'java_interop_jnienv_set_byte_array_region'.
09-09 14:37:41.995 D/Mono    (19158): Found as 'java_interop_jnienv_set_byte_array_region'.
09-09 14:37:41.999 D/Mono    (19158): DllImport searching in: '__Internal' ('(null)').
09-09 14:37:41.999 D/Mono    (19158): Searching for 'java_interop_jnienv_get_byte_array_region'.
09-09 14:37:41.999 D/Mono    (19158): Probing 'java_interop_jnienv_get_byte_array_region'.
09-09 14:37:41.999 D/Mono    (19158): Found as 'java_interop_jnienv_get_byte_array_region'.
09-09 14:37:42.173 D/Mono    (19158): Loading reference 9 of netstandard.dll asmctx DEFAULT, looking for System.Numerics, Version=2.0.5.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
09-09 14:37:42.173 D/Mono    (19158): Image addref System.Numerics[0xd0c1fec0] (asmctx DEFAULT) -> System.Numerics.dll[0xcfbfd800]: 2
09-09 14:37:42.173 D/Mono    (19158): Prepared to set up assembly 'System.Numerics' (System.Numerics.dll)
09-09 14:37:42.173 D/Mono    (19158): Assembly System.Numerics[0xd0c1fec0] added to domain RootDomain, ref_count=1
09-09 14:37:42.173 D/Mono    (19158): AOT: image 'System.Numerics.dll.so' not found: (null)
09-09 14:37:42.173 D/Mono    (19158): AOT: image '/Users/builder/jenkins/workspace/archive-mono/2019-02/android/release/sdks/out/android-x86-release/lib/mono/aot-cache/x86/System.Numerics.dll.so' not found: (null)
09-09 14:37:42.174 D/Mono    (19158): Config attempting to parse: 'System.Numerics.dll.config'.
09-09 14:37:42.174 D/Mono    (19158): Config attempting to parse: '/Users/builder/jenkins/workspace/archive-mono/2019-02/android/release/sdks/out/android-x86-release/etc/mono/assemblies/System.Numerics/System.Numerics.config'.
09-09 14:37:42.174 D/Mono    (19158): Assembly Ref addref netstandard[0xf016e6a0] -> System.Numerics[0xd0c1fec0]: 2
09-09 14:37:42.174 D/Mono    (19158): Loading reference 0 of System.Numerics.dll asmctx DEFAULT, looking for mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e
09-09 14:37:42.174 D/Mono    (19158): Assembly Ref addref System.Numerics[0xd0c1fec0] -> mscorlib[0xf0162580]: 64
Loaded assembly: System.Numerics.dll [External]
09-09 14:37:42.252 D/Mono    (19158): Loading reference 10 of netstandard.dll asmctx DEFAULT, looking for System.Runtime.Serialization, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e
09-09 14:37:42.252 D/Mono    (19158): Image addref System.Runtime.Serialization[0xcf7bcd80] (asmctx DEFAULT) -> System.Runtime.Serialization.dll[0xcfbfdd00]: 2
09-09 14:37:42.252 D/Mono    (19158): Prepared to set up assembly 'System.Runtime.Serialization' (System.Runtime.Serialization.dll)
09-09 14:37:42.252 D/Mono    (19158): Assembly System.Runtime.Serialization[0xcf7bcd80] added to domain RootDomain, ref_count=1
09-09 14:37:42.252 D/Mono    (19158): AOT: image 'System.Runtime.Serialization.dll.so' not found: (null)
09-09 14:37:42.252 D/Mono    (19158): AOT: image '/Users/builder/jenkins/workspace/archive-mono/2019-02/android/release/sdks/out/android-x86-release/lib/mono/aot-cache/x86/System.Runtime.Serialization.dll.so' not found: (null)
09-09 14:37:42.252 D/Mono    (19158): Config attempting to parse: 'System.Runtime.Serialization.dll.config'.
09-09 14:37:42.252 D/Mono    (19158): Config attempting to parse: '/Users/builder/jenkins/workspace/archive-mono/2019-02/android/release/sdks/out/android-x86-release/etc/mono/assemblies/System.Runtime.Serialization/System.Runtime.Serialization.config'.
09-09 14:37:42.252 D/Mono    (19158): Assembly Ref addref netstandard[0xf016e6a0] -> System.Runtime.Serialization[0xcf7bcd80]: 2
09-09 14:37:42.252 D/Mono    (19158): Loading reference 0 of System.Runtime.Serialization.dll asmctx DEFAULT, looking for mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e
09-09 14:37:42.252 D/Mono    (19158): Assembly Ref addref System.Runtime.Serialization[0xcf7bcd80] -> mscorlib[0xf0162580]: 65
Loaded assembly: System.Runtime.Serialization.dll [External]
09-09 14:37:42.277 D/Mono    (19158): Loading reference 3 of netstandard.dll asmctx DEFAULT, looking for System.Data, Version=2.0.5.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
09-09 14:37:42.278 D/Mono    (19158): Image addref System.Data[0xcf7bce40] (asmctx DEFAULT) -> System.Data.dll[0xcfbfbf00]: 2
09-09 14:37:42.278 D/Mono    (19158): Prepared to set up assembly 'System.Data' (System.Data.dll)
09-09 14:37:42.278 D/Mono    (19158): Assembly System.Data[0xcf7bce40] added to domain RootDomain, ref_count=1
09-09 14:37:42.278 D/Mono    (19158): AOT: image 'System.Data.dll.so' not found: (null)
09-09 14:37:42.278 D/Mono    (19158): AOT: image '/Users/builder/jenkins/workspace/archive-mono/2019-02/android/release/sdks/out/android-x86-release/lib/mono/aot-cache/x86/System.Data.dll.so' not found: (null)
09-09 14:37:42.278 D/Mono    (19158): Config attempting to parse: 'System.Data.dll.config'.
09-09 14:37:42.278 D/Mono    (19158): Config attempting to parse: '/Users/builder/jenkins/workspace/archive-mono/2019-02/android/release/sdks/out/android-x86-release/etc/mono/assemblies/System.Data/System.Data.config'.
09-09 14:37:42.278 D/Mono    (19158): Assembly Ref addref netstandard[0xf016e6a0] -> System.Data[0xcf7bce40]: 2
09-09 14:37:42.278 D/Mono    (19158): Loading reference 0 of System.Data.dll asmctx DEFAULT, looking for mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e
09-09 14:37:42.278 D/Mono    (19158): Assembly Ref addref System.Data[0xcf7bce40] -> mscorlib[0xf0162580]: 66
09-09 14:37:42.278 D/Mono    (19158): Loading reference 2 of System.Data.dll asmctx DEFAULT, looking for System.Xml, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e
09-09 14:37:42.278 D/Mono    (19158): Assembly Ref addref System.Data[0xcf7bce40] -> System.Xml[0xebce8a80]: 4
Loaded assembly: System.Data.dll [External]
09-09 14:37:42.289 D/Mono    (19158): Loading reference 1 of System.Data.dll asmctx DEFAULT, looking for System, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e
09-09 14:37:42.289 D/Mono    (19158): Assembly Ref addref System.Data[0xcf7bce40] -> System[0xf016d200]: 8
09-09 14:37:42.290 D/Mono    (19158): Loading reference 4 of System.Data.dll asmctx DEFAULT, looking for System.Core, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e
09-09 14:37:42.290 D/Mono    (19158): Assembly Ref addref System.Data[0xcf7bce40] -> System.Core[0xf016d7a0]: 6
Loaded assembly: Anonymously Hosted DynamicMethods Assembly [External]
09-09 14:37:43.017 D/Mono    (19158): Loading reference 9 of SQLite-net.dll asmctx DEFAULT, looking for SQLitePCLRaw.batteries_v2, Version=1.1.11.121, Culture=neutral, PublicKeyToken=8226ea5df37bcae9
09-09 14:37:43.017 D/Mono    (19158): Assembly Ref addref SQLite-net[0xf01627c0] -> SQLitePCLRaw.batteries_v2[0xf0162880]: 2
09-09 14:37:43.019 D/Mono    (19158): Loading reference 1 of SQLitePCLRaw.batteries_v2.dll asmctx DEFAULT, looking for SQLitePCLRaw.provider.e_sqlite3, Version=1.1.11.121, Culture=neutral, PublicKeyToken=9c301db686d0bd12
09-09 14:37:43.019 D/Mono    (19158): Assembly Ref addref SQLitePCLRaw.batteries_v2[0xf0162880] -> SQLitePCLRaw.provider.e_sqlite3[0xf01629a0]: 2
09-09 14:37:43.019 D/Mono    (19158): Loading reference 1 of SQLitePCLRaw.provider.e_sqlite3.dll asmctx DEFAULT, looking for SQLitePCLRaw.core, Version=1.1.11.121, Culture=neutral, PublicKeyToken=1488e028ca7ab535
09-09 14:37:43.019 D/Mono    (19158): Assembly Ref addref SQLitePCLRaw.provider.e_sqlite3[0xf01629a0] -> SQLitePCLRaw.core[0xf01628e0]: 3
09-09 14:37:43.019 D/Mono    (19158): Loading reference 2 of SQLitePCLRaw.batteries_v2.dll asmctx DEFAULT, looking for SQLitePCLRaw.core, Version=1.1.11.121, Culture=neutral, PublicKeyToken=1488e028ca7ab535
09-09 14:37:43.020 D/Mono    (19158): Assembly Ref addref SQLitePCLRaw.batteries_v2[0xf0162880] -> SQLitePCLRaw.core[0xf01628e0]: 4
09-09 14:37:43.024 D/Mono    (19158): DllImport attempting to load: 'e_sqlite3'.
09-09 14:37:43.024 D/Mono    (19158): DllImport error loading library './e_sqlite3': '(null)'.
09-09 14:37:43.025 D/Mono    (19158): DllImport loaded library './libe_sqlite3.so'.
09-09 14:37:43.025 D/Mono    (19158): DllImport searching in: 'e_sqlite3' ('./libe_sqlite3.so').
09-09 14:37:43.025 D/Mono    (19158): Searching for 'sqlite3_libversion_number'.
09-09 14:37:43.037 D/Mono    (19158): DllImport searching in: 'e_sqlite3' ('./libe_sqlite3.so').
09-09 14:37:43.037 D/Mono    (19158): Searching for 'sqlite3_open_v2'.
09-09 14:37:43.057 D/Mono    (19158): DllImport searching in: 'e_sqlite3' ('./libe_sqlite3.so').
09-09 14:37:43.057 D/Mono    (19158): Searching for 'sqlite3_busy_timeout'.
09-09 14:37:43.069 D/Mono    (19158): DllImport searching in: 'e_sqlite3' ('./libe_sqlite3.so').
09-09 14:37:43.069 D/Mono    (19158): Searching for 'sqlite3_prepare_v2'.
09-09 14:37:43.084 D/Mono    (19158): DllImport searching in: 'e_sqlite3' ('./libe_sqlite3.so').
09-09 14:37:43.084 D/Mono    (19158): Searching for 'sqlite3_step'.
09-09 14:37:43.087 D/Mono    (19158): DllImport searching in: 'e_sqlite3' ('./libe_sqlite3.so').
09-09 14:37:43.087 D/Mono    (19158): Searching for 'sqlite3_column_type'.
09-09 14:37:43.088 D/Mono    (19158): Loading reference 5 of SQLite-net.dll asmctx DEFAULT, looking for System.Reflection, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
09-09 14:37:43.088 D/Mono    (19158): Image addref System.Reflection[0xcf7be520] (asmctx DEFAULT) -> System.Reflection.dll[0xcfbff600]: 2
09-09 14:37:43.088 D/Mono    (19158): Prepared to set up assembly 'System.Reflection' (System.Reflection.dll)
09-09 14:37:43.089 D/Mono    (19158): Assembly System.Reflection[0xcf7be520] added to domain RootDomain, ref_count=1
09-09 14:37:43.089 D/Mono    (19158): AOT: image 'System.Reflection.dll.so' not found: (null)
09-09 14:37:43.089 D/Mono    (19158): AOT: image '/Users/builder/jenkins/workspace/archive-mono/2019-02/android/release/sdks/out/android-x86-release/lib/mono/aot-cache/x86/System.Reflection.dll.so' not found: (null)
09-09 14:37:43.089 D/Mono    (19158): Config attempting to parse: 'System.Reflection.dll.config'.
09-09 14:37:43.089 D/Mono    (19158): Config attempting to parse: '/Users/builder/jenkins/workspace/archive-mono/2019-02/android/release/sdks/out/android-x86-release/etc/mono/assemblies/System.Reflection/System.Reflection.config'.
09-09 14:37:43.089 D/Mono    (19158): Assembly Ref addref SQLite-net[0xf01627c0] -> System.Reflection[0xcf7be520]: 2
09-09 14:37:43.089 D/Mono    (19158): Loading reference 0 of System.Reflection.dll asmctx DEFAULT, looking for mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e
09-09 14:37:43.089 D/Mono    (19158): Assembly Ref addref System.Reflection[0xcf7be520] -> mscorlib[0xf0162580]: 67
09-09 14:37:43.089 D/Mono    (19158): Loading reference 12 of SQLite-net.dll asmctx DEFAULT, looking for System.Globalization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
09-09 14:37:43.089 D/Mono    (19158): Image addref System.Globalization[0xcf7be400] (asmctx DEFAULT) -> System.Globalization.dll[0xcfbffb00]: 2
09-09 14:37:43.089 D/Mono    (19158): Prepared to set up assembly 'System.Globalization' (System.Globalization.dll)
09-09 14:37:43.089 D/Mono    (19158): Assembly System.Globalization[0xcf7be400] added to domain RootDomain, ref_count=1
09-09 14:37:43.089 D/Mono    (19158): AOT: image 'System.Globalization.dll.so' not found: (null)
09-09 14:37:43.089 D/Mono    (19158): AOT: image '/Users/builder/jenkins/workspace/archive-mono/2019-02/android/release/sdks/out/android-x86-release/lib/mono/aot-cache/x86/System.Globalization.dll.so' not found: (null)
09-09 14:37:43.090 D/Mono    (19158): Config attempting to parse: 'System.Globalization.dll.config'.
09-09 14:37:43.090 D/Mono    (19158): Config attempting to parse: '/Users/builder/jenkins/workspace/archive-mono/2019-02/android/release/sdks/out/android-x86-release/etc/mono/assemblies/System.Globalization/System.Globalization.config'.
09-09 14:37:43.090 D/Mono    (19158): Assembly Ref addref SQLite-net[0xf01627c0] -> System.Globalization[0xcf7be400]: 2
09-09 14:37:43.090 D/Mono    (19158): Loading reference 0 of System.Globalization.dll asmctx DEFAULT, looking for mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e
09-09 14:37:43.090 D/Mono    (19158): Assembly Ref addref System.Globalization[0xcf7be400] -> mscorlib[0xf0162580]: 68
09-09 14:37:43.090 D/Mono    (19158): Loading reference 2 of System.Runtime.dll asmctx DEFAULT, looking for System, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e
09-09 14:37:43.090 D/Mono    (19158): Assembly Ref addref System.Runtime[0xebce88a0] -> System[0xf016d200]: 9
Loaded assembly: System.Reflection.dll [External]
Loaded assembly: System.Globalization.dll [External]
09-09 14:37:43.112 D/Mono    (19158): DllImport searching in: 'e_sqlite3' ('./libe_sqlite3.so').
09-09 14:37:43.112 D/Mono    (19158): Searching for 'sqlite3_column_text'.
09-09 14:37:43.116 D/Mono    (19158): DllImport searching in: 'e_sqlite3' ('./libe_sqlite3.so').
09-09 14:37:43.116 D/Mono    (19158): Searching for 'sqlite3_finalize'.
09-09 14:37:43.121 D/Mono    (19158): Loading reference 8 of SQLite-net.dll asmctx DEFAULT, looking for System.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
09-09 14:37:43.122 D/Mono    (19158): Image addref System.Linq[0xcf7be460] (asmctx DEFAULT) -> System.Linq.dll[0xce8d1000]: 2
09-09 14:37:43.122 D/Mono    (19158): Prepared to set up assembly 'System.Linq' (System.Linq.dll)
09-09 14:37:43.122 D/Mono    (19158): Assembly System.Linq[0xcf7be460] added to domain RootDomain, ref_count=1
09-09 14:37:43.122 D/Mono    (19158): AOT: image 'System.Linq.dll.so' not found: (null)
09-09 14:37:43.122 D/Mono    (19158): AOT: image '/Users/builder/jenkins/workspace/archive-mono/2019-02/android/release/sdks/out/android-x86-release/lib/mono/aot-cache/x86/System.Linq.dll.so' not found: (null)
Loaded assembly: System.Linq.dll [External]09-09 14:37:43.122 D/Mono    (19158): Config attempting to parse: 'System.Linq.dll.config'.

09-09 14:37:43.122 D/Mono    (19158): Config attempting to parse: '/Users/builder/jenkins/workspace/archive-mono/2019-02/android/release/sdks/out/android-x86-release/etc/mono/assemblies/System.Linq/System.Linq.config'.
09-09 14:37:43.122 D/Mono    (19158): Assembly Ref addref SQLite-net[0xf01627c0] -> System.Linq[0xcf7be460]: 2
09-09 14:37:43.122 D/Mono    (19158): Loading reference 1 of System.Linq.dll asmctx DEFAULT, looking for System.Core, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e
09-09 14:37:43.122 D/Mono    (19158): Assembly Ref addref System.Linq[0xcf7be460] -> System.Core[0xf016d7a0]: 7
09-09 14:37:43.133 D/Mono    (19158): Loading reference 10 of SQLite-net.dll asmctx DEFAULT, looking for System.Threading, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
09-09 14:37:43.133 D/Mono    (19158): Image addref System.Threading[0xcf7be580] (asmctx DEFAULT) -> System.Threading.dll[0xce8d1500]: 2
09-09 14:37:43.133 D/Mono    (19158): Prepared to set up assembly 'System.Threading' (System.Threading.dll)
09-09 14:37:43.134 D/Mono    (19158): Assembly System.Threading[0xcf7be580] added to domain RootDomain, ref_count=1
09-09 14:37:43.134 D/Mono    (19158): AOT: image 'System.Threading.dll.so' not found: (null)
09-09 14:37:43.134 D/Mono    (19158): AOT: image '/Users/builder/jenkins/workspace/archive-mono/2019-02/android/release/sdks/out/android-x86-release/lib/mono/aot-cache/x86/System.Threading.dll.so' not found: (null)
09-09 14:37:43.134 D/Mono    (19158): Config attempting to parse: 'System.Threading.dll.config'.
09-09 14:37:43.134 D/Mono    (19158): Config attempting to parse: '/Users/builder/jenkins/workspace/archive-mono/2019-02/android/release/sdks/out/android-x86-release/etc/mono/assemblies/System.Threading/System.Threading.config'.
09-09 14:37:43.134 D/Mono    (19158): Assembly Ref addref SQLite-net[0xf01627c0] -> System.Threading[0xcf7be580]: 2
09-09 14:37:43.134 D/Mono    (19158): Loading reference 0 of System.Threading.dll asmctx DEFAULT, looking for mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e
09-09 14:37:43.134 D/Mono    (19158): Assembly Ref addref System.Threading[0xcf7be580] -> mscorlib[0xf0162580]: 69
Loaded assembly: System.Threading.dll [External]
09-09 14:37:43.145 D/Mono    (19158): Loading reference 1 of System.Collections.dll asmctx DEFAULT, looking for System.Core, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e
09-09 14:37:43.145 D/Mono    (19158): Assembly Ref addref System.Collections[0xd0c204c0] -> System.Core[0xf016d7a0]: 8
09-09 14:37:43.148 D/Mono    (19158): Loading reference 11 of SQLite-net.dll asmctx DEFAULT, looking for System.Reflection.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
09-09 14:37:43.148 D/Mono    (19158): Image addref System.Reflection.Extensions[0xcf7be4c0] (asmctx DEFAULT) -> System.Reflection.Extensions.dll[0xce8d1a00]: 2
09-09 14:37:43.148 D/Mono    (19158): Prepared to set up assembly 'System.Reflection.Extensions' (System.Reflection.Extensions.dll)
09-09 14:37:43.148 D/Mono    (19158): Assembly System.Reflection.Extensions[0xcf7be4c0] added to domain RootDomain, ref_count=1
09-09 14:37:43.148 D/Mono    (19158): AOT: image 'System.Reflection.Extensions.dll.so' not found: (null)
09-09 14:37:43.148 D/Mono    (19158): AOT: image '/Users/builder/jenkins/workspace/archive-mono/2019-02/android/release/sdks/out/android-x86-release/lib/mono/aot-cache/x86/System.Reflection.Extensions.dll.so' not found: (null)
09-09 14:37:43.148 D/Mono    (19158): Config attempting to parse: 'System.Reflection.Extensions.dll.config'.
09-09 14:37:43.148 D/Mono    (19158): Config attempting to parse: '/Users/builder/jenkins/workspace/archive-mono/2019-02/android/release/sdks/out/android-x86-release/etc/mono/assemblies/System.Reflection.Extensions/System.Reflection.Extensions.config'.
09-09 14:37:43.148 D/Mono    (19158): Assembly Ref addref SQLite-net[0xf01627c0] -> System.Reflection.Extensions[0xcf7be4c0]: 2
09-09 14:37:43.148 D/Mono    (19158): Loading reference 0 of System.Reflection.Extensions.dll asmctx DEFAULT, looking for mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e
09-09 14:37:43.148 D/Mono    (19158): Assembly Ref addref System.Reflection.Extensions[0xcf7be4c0] -> mscorlib[0xf0162580]: 70
Loaded assembly: System.Reflection.Extensions.dll [External]
09-09 14:37:43.246 D/Mono    (19158): DllImport searching in: 'e_sqlite3' ('./libe_sqlite3.so').
09-09 14:37:43.247 D/Mono    (19158): Searching for 'sqlite3_column_count'.
09-09 14:37:43.249 D/Mono    (19158): DllImport searching in: 'e_sqlite3' ('./libe_sqlite3.so').
09-09 14:37:43.249 D/Mono    (19158): Searching for 'sqlite3_column_name'.
09-09 14:37:43.262 D/Mono    (19158): DllImport searching in: 'e_sqlite3' ('./libe_sqlite3.so').
09-09 14:37:43.262 D/Mono    (19158): Searching for 'sqlite3_column_int'.
09-09 14:37:43.714 D/Mono    (19158): DllImport searching in: 'e_sqlite3' ('./libe_sqlite3.so').
09-09 14:37:43.715 D/Mono    (19158): Searching for 'sqlite3_close_v2'.
**System.ArgumentException:** 'method arguments are incompatible'

It crashes most likely because you have an unhandled exception in an async void fire and forget function. There may be an issue with the insert, but because of the async void you are unable to catch the thrown exception.

avoid async void except for actual event handlers .

Reference Async/Await - Best Practices in Asynchronous Programming

Refactor

Location

[Table]
public class Location {
    public string Location_Desc { get; set; }
    public string LocationCode { get; set; }
}

MainPage

public MainPage() {
    InitializeComponent();
} 

static Lazy<HttpClient> httpClient = new Lazy<HttpClient>();

public async Task GetLocations() {        
    var response = await httpClient.Value.GetStringAsync("my API url is here");
    var locations = JsonConvert.DeserializeObject<List<Location>>(response);
    using(SQLiteConnection conn = new SQLiteConnection(App.DatabaseLocation)) {
        conn.CreateTable<Location>();
        foreach(var location in locations) {
            conn.Insert(location);
        }
        //OR
        //conn.InsertAll(locations);
        conn.Close();
    }
}

//async-void allowed here because this is an event handler.
private async void Button_Clicked(object sender, EventArgs e) {
    await GetLocations();

    //await Navigation.PushAsync(new LocationPage());
    //this code navigates to the next page in the app
}

And GetLocations can wrap its content in a try-catch to handle any thrown exceptions.

You are passing a collection when a single Location is expected for Insert . Use conn.InsertAll(locations) instead

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM