New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Xamarin Android - JsonSerializationException: Error getting value from '[FIELD]' on '[METHOD]' #1113
Comments
I am unable to reproduce it. Tried it with XA Version: 8.1.0.22 If it still happens for you, please attach whole XA project, which reproduces the issue. |
Hi, it's a big xamarin project with many references and I can't attach all the project. The problems seems to depend by dynamic method creation during NewtonSoft serialization but I don't know how it happens and why. It happens in Release mode and not in Debug mode compilation. I saw that loaded assembly in debug mode are : Loaded assembly: Microsoft.CSharp.dll [External] My project can't compile in Release mode with Linking "SDK Assembly Only" but only with "NONE". I attach all compile detailed debug information if it can help. |
From RELEASE_MODE_LINKING_SDKASSEMBLYONLY.txt
I suspect that you're hitting xamarin/xamarin-macios#3215, the fix for which involves a null check within
The fix has not yet been integrated on xamarin-android/master; the last URL above is on xamarin-android/d15-6, which is for Xamarin.Android 8.2 (currently in beta). However, I don't know when that fix will actually be released. |
Fixes: xamarin#4996 Changes: xamarin/monodroid@92b9cce...a9ae74d * xamarin/monodroid@a9ae74d47: Bump to xamarin/android-sdk-installer@1928338b (xamarin#1113) * xamarin/monodroid@4afc0d960: [RuntimeService] Update Shared runtime to use `getExternalFilesDir` (xamarin#1111)
Fixes: xamarin#4996 Changes: xamarin/monodroid@92b9cce...a9ae74d * xamarin/monodroid@a9ae74d47: Bump to xamarin/android-sdk-installer@1928338b (xamarin#1113) * xamarin/monodroid@4afc0d960: [RuntimeService] Update Shared runtime to use `getExternalFilesDir` (xamarin#1111)
Fixes: #4996 Changes: xamarin/monodroid@92b9cce...a9ae74d * xamarin/monodroid@a9ae74d47: Bump to xamarin/android-sdk-installer@1928338b (#1113) * xamarin/monodroid@4afc0d960: [RuntimeService] Update Shared runtime to use `getExternalFilesDir` (#1111)
Copied from JamesNK/Newtonsoft.Json#1537 @lorisgiglio
Environment
Visual Studio 2015
Xamarin 4.8.0.754
Xamarin Android 8.1.0.13
Xamarin Android SDK 8.1.1.1
Newtonsoft.Json 10.0.3
Source/destination types
Expected behavior
It has to serialize the simple object
Actual behavior
12-13 10:49:28.412 9122 9122 I MonoDroid: UNHANDLED EXCEPTION:
12-13 10:49:28.419 9122 9122 I MonoDroid: Newtonsoft.Json.JsonSerializationException: Error getting value from 'field1' on 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'. ---> System.MissingMethodException: Method 'System.Reflection.Emit.DynamicMethod.set_ProfileAPICheck' not found.
12-13 10:49:28.419 9122 9122 I MonoDroid: at System.Linq.Expressions.Compiler.LambdaCompiler.Compile (System.Linq.Expressions.LambdaExpression lambda, System.Runtime.CompilerServices.DebugInfoGenerator debugInfoGenerator) [0x0000f] in :0
12-13 10:49:28.419 9122 9122 I MonoDroid: at System.Linq.Expressions.LambdaExpression.Compile () [0x00000] in :0
12-13 10:49:28.419 9122 9122 I MonoDroid: at Newtonsoft.Json.Utilities.ExpressionReflectionDelegateFactory.CreateGet[T] (System.Reflection.PropertyInfo propertyInfo) [0x0007c] in :0
12-13 10:49:28.419 9122 9122 I MonoDroid: at Newtonsoft.Json.Utilities.ReflectionDelegateFactory.CreateGet[T] (System.Reflection.MemberInfo memberInfo) [0x0000a] in :0
12-13 10:49:28.419 9122 9122 I MonoDroid: at Newtonsoft.Json.Serialization.ExpressionValueProvider.GetValue (System.Object target) [0x0000e] in :0
12-13 10:49:28.419 9122 9122 I MonoDroid: --- End of inner exception stack trace ---
12-13 10:49:28.419 9122 9122 I MonoDroid: at Newtonsoft.Json.Serialization.ExpressionValueProvider.GetValue (System.Object target) [0x00054] in :0
12-13 10:49:28.419 9122 9122 I MonoDroid: at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.CalculatePropertyValues (Newtonsoft.Json.JsonWriter writer, System.Object value, Newtonsoft.Json.Serialization.JsonContainerContract contract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonProperty property, Newtonsoft.Json.Serialization.JsonContract& memberContract, System.Object& memberValue) [0x00066] in :0
12-13 10:49:28.419 9122 9122 I MonoDroid: at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeObject (Newtonsoft.Json.JsonWriter writer, System.Object value, Newtonsoft.Json.Serialization.JsonObjectContract contract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract collectionContract, Newtonsoft.Json.Serialization.JsonProperty containerProperty) [0x0008d] in :0
12-13 10:49:28.419 9122 9122 I MonoDroid: at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeValue (Newtonsoft.Json.JsonWriter writer, System.Object value, Newtonsoft.Json.Serialization.JsonContract valueContract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerProperty) [0x000b0] in :0
12-13 10:49:28.419 9122 9122 I MonoDroid: at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.Serialize (Newtonsoft.Json.JsonWriter jsonWriter, System.Object value, System.Type objectType) [0x00079] in :0
12-13 10:49:28.419 9122 9122 I MonoDroid: at Newtonsoft.Json.JsonSerializer.SerializeInternal (Newtonsoft.Json.JsonWriter jsonWriter, System.Object value, System.Type objectType) [0x00253] in :0
12-13 10:49:28.419 9122 9122 I MonoDroid: at Newtonsoft.Json.JsonSerializer.Serialize (Newtonsoft.Json.JsonWriter jsonWriter, System.Object value, System.Type objectType) [0x00000] in :0
12-13 10:49:28.419 9122 9122 I MonoDroid: at Newtonsoft.Json.JsonConvert.SerializeObjectInternal (System.Object value, System.Type type, Newtonsoft.Json.JsonSerializer jsonSerializer) [0x00028] in :0
12-13 10:49:28.419 9122 9122 I MonoDroid: at Newtonsoft.Json.JsonConvert.SerializeObject (System.Object value, System.Type type, Newtonsoft.Json.JsonSerializerSettings settings) [0x00007] in :0
12-13 10:49:28.419 9122 9122 I MonoDroid: at Newtonsoft.Json.JsonConvert.SerializeObject (System.Object value, Newtonsoft.Json.JsonSerializerSettings settings) [0x00000] in :0
Steps to reproduce
The text was updated successfully, but these errors were encountered: