Search Issue Tracker

Won't Fix

Votes

10

Found in

2018.2.5f1

Issue ID

1075706

Regression

No

[IL2CPP] NotSupportedExceptions exception is thrown in build with Newtonsoft.Json plugin

IL2CPP

-

Steps to reproduce:
1. Download attached project
2. Build standalone project on IL2CPP backend
3. Launch build project
4. Notice exception in development console

Expected results: No exception is thrown
Actual results: Editors throws out an exception

Reproduced with: 2018.3.0a11, 2018.2.6f1, 2018.1.9f1, 2017.4.10f1

Exception:
NullReferenceException: Object reference not set to an instance of an object.
at System.Linq.Expressions.Interpreter.LightLambda.MakeRunDelegateCtor (System.Type delegateType) [0x00000] in <00000000000000000000000000000000>:0
at System.Linq.Expressions.Interpreter.LightLambda.GetRunDelegateCtor (System.Type delegateType) [0x00000] in <00000000000000000000000000000000>:0
at System.Linq.Expressions.Interpreter.LightDelegateCreator.CreateDelegate () [0x00000] in <00000000000000000000000000000000>:0
at Newtonsoft.Json.Utilities.ExpressionReflectionDelegateFactory.CreateSet[T] (System.Reflection.PropertyInfo propertyInfo) [0x00000] in <00000000000000000000000000000000>:0
at Newtonsoft.Json.Utilities.ReflectionDelegateFactory.CreateSet[T] (System.Reflection.MemberInfo memberInfo) [0x00000] in <00000000000000000000000000000000>:0
at Newtonsoft.Json.Serialization.ExpressionValueProvider.SetValue (System.Object target, System.Object value) [0x00000] in <00000000000000000000000000000000>:0
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue (Newtonsoft.Json.Serialization.JsonProperty property, Newtonsoft.Json.JsonConverter propertyConverter, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerProperty, Newtonsoft.Json.JsonReader reader, System.Object target) [0x00000] in <00000000000000000000000000000000>:0
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject (System.Object newObject, Newtonsoft.Json.JsonReader reader, Newtonsoft.Json.Serialization.JsonObjectContract contract, Newtonsoft.Json.Serialization.JsonProperty member, System.String id) [0x00000] in <00000000000000000000000000000000>:0
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject (Newtonsoft.Json.JsonReader reader, System.Type objectType, Newtonsoft.Json.Serialization.JsonContract contract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerMember, System.Object existingValue) [0x00000] in <00000000000000000000000000000000>:0
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal (Newtonsoft.Json.JsonReader reader, System.Type objectType, Newtonsoft.Json.Serialization.JsonContract contract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerMember, System.Object existingValue) [0x00000] in <00000000000000000000000000000000>:0
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize (Newtonsoft.Json.JsonReader reader, System.Type objectType, System.Boolean checkAdditionalContent) [0x00000] in <00000000000000000000000000000000>:0
at Newtonsoft.Json.JsonSerializer.DeserializeInternal (Newtonsoft.Json.JsonReader reader, System.Type objectType) [0x00000] in <00000000000000000000000000000000>:0
at Newtonsoft.Json.JsonConvert.DeserializeObject (System.String value, System.Type type, Newtonsoft.Json.JsonSerializerSettings settings) [0x00000] in <00000000000000000000000000000000>:0
at Newtonsoft.Json.JsonConvert.DeserializeObject[T] (System.String value, Newtonsoft.Json.JsonSerializerSettings settings) [0x00000] in <00000000000000000000000000000000>:0
at NewBehaviourScript.Start () [0x00000] in <00000000000000000000000000000000>:0
Rethrow as JsonSerializationException: Error setting value to 'Name' on 'Enemy'.
at Newtonsoft.Json.Serialization.ExpressionValueProvider.SetValue (System.Object target, System.Object value) [0x00000] in <00000000000000000000000000000000>:0
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue (Newtonsoft.Json.Serialization.JsonProperty property, Newtonsoft.Json.JsonConverter propertyConverter, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerProperty, Newtonsoft.Json.JsonReader reader, System.Object target) [0x00000] in <00000000000000000000000000000000>:0
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject (System.Object newObject, Newtonsoft.Json.JsonReader reader, Newtonsoft.Json.Serialization.JsonObjectContract contract, Newtonsoft.Json.Serialization.JsonProperty member, System.String id) [0x00000] in <00000000000000000000000000000000>:0
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject (Newtonsoft.Json.JsonReader reader, System.Type objectType, Newtonsoft.Json.Serialization.JsonContract contract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerMember, System.Object existingValue) [0x00000] in <00000000000000000000000000000000>:0
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal (Newtonsoft.Json.JsonReader reader, System.Type objectType, Newtonsoft.Json.Serialization.JsonContract contract, Newtonsoft.Json.Serialization.JsonProperty member, Newtonsoft.Json.Serialization.JsonContainerContract containerContract, Newtonsoft.Json.Serialization.JsonProperty containerMember, System.Object existingValue) [0x00000] in <00000000000000000000000000000000>:0
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize (Newtonsoft.Json.JsonReader reader, System.Type objectType, System.Boolean checkAdditionalContent) [0x00000] in <00000000000000000000000000000000>:0
at Newtonsoft.Json.JsonSerializer.DeserializeInternal (Newtonsoft.Json.JsonReader reader, System.Type objectType) [0x00000] in <00000000000000000000000000000000>:0
at Newtonsoft.Json.JsonConvert.DeserializeObject (System.String value, System.Type type, Newtonsoft.Json.JsonSerializerSettings settings) [0x00000] in <00000000000000000000000000000000>:0
at Newtonsoft.Json.JsonConvert.DeserializeObject[T] (System.String value, Newtonsoft.Json.JsonSerializerSettings settings) [0x00000] in <00000000000000000000000000000000>:0

  1. Resolution Note:

    For the time bring there is a work around for this issue. Include the following link.xml file in the project:

    <linker>
    <assembly fullname="System.Core">
    <type fullname="System.Linq.Expressions.Interpreter.LightLambda" preserve="all" />
    </assembly>
    </linker>

    Once the class libraries Unity uses from Mono are updated, this work around will no longer be necessary.

Comments (20)

  1. erlioniel

    Oct 10, 2021 21:07

    Don't sure about this particular library, but actually the fix helped with WebGL build and similar issue

  2. RendergonPolygons

    May 17, 2020 07:27

    doesn't work for macos, Unity 2019.3.13. Why not fix?

  3. as87dgs6asg0a

    May 16, 2020 21:48

    Your link.xml solution, not only doesn't work as it makes the app crash instead of just showing the error.

  4. as87dgs6asg0a

    May 16, 2020 21:33

    Same issue here. The workaround wont work and this is preventing me from posting my game on the Play Store.

  5. DearUnityPleaseAddSerializableDictionaries

    May 02, 2020 19:25

    The link.xml workaround does not work.

    Please can this bug be re-opened? This has negatively impacted user experience and has not been fixed for years. This bug should be prioritised.

  6. DearUnityPleaseAddSerializableDictionaries

    May 02, 2020 19:19

    Why is this marked as Won't Fix?!

    This should be fixed, it has severely negatively impacted my experience in using Unity Pro.

  7. ManuelSalvadori

    Apr 30, 2020 14:08

    I had the same issue on Android. The problem was not newtonsoft, but the fact that i was using the "dynamic" data type. Changing the type from dynamic to object solved the issue.

  8. Star_Digital_Works

    Mar 18, 2020 10:47

    After struggling with this same issue for a while I successfully migrated my project to a new JSON plugin and I can now compile using IL2CPP on Android and my JSON is working properly.

    https://github.com/jilleJr/Newtonsoft.Json-for-Unity.

  9. Qmaks2

    Feb 03, 2020 14:04

    Solution with link.xml does not help

  10. hertz-rat

    Jan 31, 2020 06:40

    I'm still getting this in 2019.3, and the link.xml fix isn't working.

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.