JsonFx with IL2CPP

1.8k views Asked by At

Constructor not working with the IL2CPP.Here is the log i get.

MissingMethodException: Method not found: 'Default constructor not found...ctor() of System.ComponentModel.ByteConverter'. at System.ArgumentNullException..ctor (System.String paramName) [0x00000] in :0 at System.Activator.CreateInstance (System.Type type, Boolean nonPublic) [0x00000] in :0 at System.Activator.CreateInstance (System.Type type) [0x00000] in :0 at System.ComponentModel.TypeDescriptor.GetConverter (System.Type type) [0x00000] in :0 at JsonFx.Json.TypeCoercionUtility.CoerceType (System.Type targetType, System.Object value) [0x00000] in :0 at JsonFx.Json.JsonReader.ReadNumber (System.Type expectedType) [0x00000] in :0 at JsonFx.Json.JsonReader.Read (System.Type expectedType, Boolean typeIsHint) [0x00000] in :0
at JsonFx.Json.JsonReader.ReadArray (System.Type arrayType) [0x00000] in :0 at JsonFx.Json.JsonReader.Read (System.Type expectedType, Boolean typeIsHint) [0x00000] in :0
at JsonFx.Json.JsonReader.ReadObject (System.Type objectType) [0x00000] in :0 at JsonFx.Json.JsonReader.Read (System.Type expectedType, Boolean typeIsHint) [0x00000] in :0 at JsonFx.Json.JsonReader.ReadObject (System.Type objectType) [0x00000] in :0 at JsonFx.Json.JsonReader.Read (System.Type expectedType, Boolean typeIsHint) [0x00000] in :0 at JsonFx.Json.JsonReader.ReadObject (System.Type objectType) [0x00000] in :0 at JsonFx.Json.JsonReader.Read (System.Type expectedType, Boolean typeIsHint) [0x00000] in :0
at JsonFx.Json.JsonReader.ReadObject (System.Type objectType) [0x00000] in :0 at JsonFx.Json.JsonReader.Read (System.Type expectedType, Boolean typeIsHint) [0x00000] in :0 at JsonFx.Json.JsonReader.Deserialize (Int32 start, System.Type type) [0x00000] in :0 at JsonFx.Json.JsonReader.Deserialize (System.String value, Int32 start, System.Type type) [0x00000] in :0 at JsonFx.Json.JsonReader.Deserialize[BGS] (System.String value) [0x00000] in :0 at GameData.ParseJson () [0x00000] in :0 at GameData.loaddata () [0x00000] in :0 at mainmenuUI.Start () [0x00000] in :0 at System.Array+InternalEnumerator1[System.Collections.Hashtable+Slot].get_Current () [0x00000] in <filename unknown>:0 System.InternalEnumerator1:get_Current()

2

There are 2 answers

0
Josh Peterson On

This does look like a problem with stripping. Note that although the "Stripping Level" setting in the Unity Editor may be set to "Disable" the IL2CPP scripting backend will still perform the equivalent byte code stripping.

As Marius mentioned, you will need to explicitly tell the Unity build toolchain to not strip the ByteConverter type. You can add a link.xml file in your Assets directory with the following content:

<linker>
  <assembly fullname="System">
    <type fullname="System.ComponentModel.ByteConverter" preserve="all"/>
  </assembly>
</linker>

This will keep everything in the ByteConverter type (the preserve="all" element), which might be a bit too much, but you can follow the documentation to minimize the amount of IL code that is kept in the assembly.

1
Marius Junak On

Its a stripping Error. With IL2CPP assembly stripping is always enabled. Try updating to the latest Unity-Version. Otherwise you can explicitly prevent namespaces from stripping.