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
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
-
The_MAZZTer
Jan 24, 2020 17:06
Still seeing this issue in 2019.2.19 when building a project for WebGL.
There is a bug in IL2CPP with using Dictionary with DataContractJsonSerializer, and of course JsonUtility doesn't support them at all, so a third party library is really the only option.
I can confirm this workaround works.
-
deram_scholzara
Nov 12, 2019 22:50
I'm confused by the status of this bug, as the resolution note says: Once the class libraries Unity uses from Mono are updated, this work around will no longer be necessary.
This implies to me that it is fixed in a later version of Unity, yet this is resolved as "won't fix". Can we please list this with the version of Unity in which it is fixed so that we know when the workaround is no longer necessary?
-
KanraLovesU
Sep 16, 2019 19:49
Exactly the same problem as FLURINJENAL. Unity version 2018.3.6, Android, IL2CPP, .NET 4.x, and ARM64. Included link.xml file and it doesn't appear to change the result.
-
FlurinJenal
Aug 19, 2019 13:19
I created the link.xml file with the above content and put it in my assets folder. Built the project for Android, IL2CPP, .NET 4.x, ARM64 and run into the exact same exception. Do iIhave to do something with the xml file or what is wrong?
-
stonstad
Jul 16, 2019 16:52
Still an active issue in 2019.1.8f1.
-
smenyhart
Apr 17, 2019 22:01
link.xml workaround works, and is still required in Unity 2019.1.0f1
-
MAlshair
Apr 15, 2019 00:46
I don't know why it crashed your editor. It worked with me in Unity 2018.3.11f1 to solve my Json problem. But I didn't have any luck solving my EFCore problem.
-
jarmohh
Mar 02, 2019 08:37
That link.xml crash unity editor totally.
-
JoshPeterson
Sep 06, 2018 18:37
Also, note that the Api Compatibility Level of .NET Standard 2.0 is required for this code to work in Unity 2018.2. In Unity 2018.3 and later, that is not the case. This work around will work with either Api Compatibility Level.
-
JoshPeterson
Sep 05, 2018 19:39
To work around this issue, add the following link.xml to the Assets folder of the Unity project:
<linker>
<assembly fullname="System.Core">
<type fullname="System.Linq.Expressions.Interpreter.LightLambda" preserve="all" />
</assembly>
</linker>
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- [VFX] Custom HLSL with 'int' parameter, without the 'in/out/inout' access modifier is not supported
- [Windows] Lens Flare doesn't work in the Lens Flare Showroom URP Sample Scene
- Crash on ujob_execute_job while using OverlapBoxCommand when collisions are more than maxHits
- The validity of the multiple handles can behave differently based on the load/release operations order, when multiple Addressables.LoadAssetAsync and Addressables.Release are used to load and release the same Addressable Asset
- Dynamic text is rendered in the background when it is inside the <font> tag
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.