问题
I am using Xamarin to send data to a private server. I serialize some data which is an array of states objects consisting of an ID (int) and DateTime. When the code hits this method
JsonConvert.SerializeObject(currentStates);
The app crashes on the emulator with the following lines in the output window
09-14 10:46:52.677 D/Mono ( 3313): Config attempting to parse:
'System.Numerics.dll.config'.
09-14 10:46:52.677 D/Mono ( 3313): Config attempting to parse:
'/usr/local/etc/mono/assemblies/System.Numerics/System.Numerics.config'.
09-14 10:46:52.677 D/Mono ( 3313): Assembly Ref addref
System.Runtime.Numerics[0x9930e520] -> System.Numerics[0x9930e4c0]: 2
09-14 10:46:52.677 D/Mono ( 3313): Assembly Ref addref
System.Numerics[0x9930e4c0] -> mscorlib[0xab19ce40]: 74
Loaded assembly: System.Runtime.Numerics.dll [External]
Loaded assembly: System.Numerics.dll [External]
09-14 10:46:52.715 D/Mono ( 3313): Assembly Ref addref
Newtonsoft.Json[0xab19dbc0] -> System.Reflection.Extensions[0xb402d800]: 6
09-14 10:46:52.747 F/ ( 3313): * Assertion at
/Users/builder/jenkins/workspace/xamarin-android/xamarin-
android/external/mono/mono/metadata/metadata.c:1062, condition `index <
meta->heap_us.size' not met
09-14 10:46:52.747 F/libc ( 3313): Fatal signal 6 (SIGABRT), code -6 in
tid 3313 ()
I have the latest version of visual studio enterprise
Microsoft Visual Studio Enterprise 2017
Version 15.3.4
VisualStudio.15.Release/15.3.4+26730.15
Microsoft .NET Framework
Version 4.7.02046
Installed Version: Enterprise
JetBrains ReSharper Ultimate 2017.2 Build 109.0.20170824.131346
Xamarin 4.6.3.4 (0841c2aaf)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.
Xamarin.Android SDK 7.4.3.1 (18558b4)
Xamarin.Android Reference Assemblies and MSBuild support.
Xamarin.iOS and Xamarin.Mac SDK 10.12.3.3 (8a39106)
Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.
I am also using Android SDK 7.1. I suspected this line describes the problem
09-14 10:46:52.747 F/ ( 3313): * Assertion at
/Users/builder/jenkins/workspace/xamarin-android/xamarin-
android/external/mono/mono/metadata/metadata.c:1062, condition `index <
meta->heap_us.size' not met
but I couldn't find any help on that
Please help as I have no idea why this is happening.
PS it used to work very well before but after upgrading nuget packages it worked well for a while then without any reason it kept crashing.
回答1:
It seems like this was a bug in Xamarin and after updating to the latest version everything is working fine now.
来源:https://stackoverflow.com/questions/46214899/xamarin-forms-app-crash-on-android-on-serializing-object-using-newtonsoft-json