Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

(Case 680326) IL2CPP xcode compile error

Discussion in 'iOS and tvOS' started by idunlop_oefun, Mar 13, 2015.

  1. idunlop_oefun

    idunlop_oefun

    Joined:
    Aug 31, 2010
    Posts:
    240
    Found a possible IL2CPP compile error. I think it's related to use of System.Xml. Compiles and runs fine using Mono (2.x) on an iPhone 6.
     
  2. idunlop_oefun

    idunlop_oefun

    Joined:
    Aug 31, 2010
    Posts:
    240
    Testing on 5.0.0p1. It compiles now. However, it causes an exception at runtime on iPhone 6 / Xcode 6.2.

    Code (CSharp):
    1. NotSupportedException: Failed to construct generic type 'System.Reflection.MonoProperty+Getter`2' with generic arguments [Formations, System.Collections.Generic.List`1[[Formation, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]]] at runtime.
    2.   at System.Type.MakeGenericType (System.Type gt, System.Type[] types) [0x00000] in <filename unknown>:0
    3.   at System.Type.MakeGenericType (System.Type[] typeArguments) [0x00000] in <filename unknown>:0
    4.   at UnityEngine.Events.UnityAction.EndInvoke (IAsyncResult result) [0x00000] in <filename unknown>:0
    5.   at System.Reflection.MonoProperty.CreateGetterDelegate (System.Reflection.MethodInfo method) [0x00000] in <filename unknown>:0
    6.   at System.Reflection.MonoProperty.GetValue (System.Object obj, System.Object[] index) [0x00000] in <filename unknown>:0
    7.   at System.Xml.Serialization.XmlNodeEventHandler.EndInvoke (IAsyncResult result) [0x00000] in <filename unknown>:0
    8.   at System.Xml.Serialization.XmlTypeMapMember.GetValue (System.Object ob) [0x00000] in <filename unknown>:0
    9.   at System.Xml.Serialization.XmlSerializationReaderInterpreter.ReadMembers (System.Xml.Serialization.ClassMap map, System.Object ob, Boolean isValueList, Boolean readByOrder) [0x00000] in <filename unknown>:0
    10.   at System.Xml.Serialization.XmlSerializationReaderInterpreter.ReadClassInstanceMembers (System.Xml.Serialization.XmlTypeMapping typeMap, System.Object ob) [0x00000] in <filename unknown>:0
    11.   at System.Xml.Serialization.XmlNodeEventHandler.EndInvoke (IAsyncResult result) [0x00000] in <filename unknown>:0
    12.   at System.Xml.Serialization.XmlSerializationReaderInterpreter.ReadClassInstance (System.Xml.Serialization.XmlTypeMapping typeMap, Boolean isNullable, Boolean checkType) [0x00000] in <filename unknown>:0
    13.   at System.Xml.Serialization.XmlNodeEventHandler.EndInvoke (IAsyncResult result) [0x00000] in <filename unknown>:0
    14.   at System.Xml.Serialization.XmlSerializationReaderInterpreter.ReadObject (System.Xml.Serialization.XmlTypeMapping typeMap, Boolean isNullable, Boolean checkType) [0x00000] in <filename unknown>:0
    15.   at System.Xml.Serialization.XmlNodeEventHandler.EndInvoke (IAsyncResult result) [0x00000] in <filename unknown>:0
    16.   at System.Xml.Serialization.XmlSerializationReaderInterpreter.ReadRoot (System.Xml.Serialization.XmlTypeMapping rootMap) [0x00000] in <filename unknown>:0
    17.   at System.Xml.Serialization.XmlSerializationReaderInterpreter.ReadRoot () [0x00000] in <filename unknown>:0
    18.   at System.Xml.Serialization.XmlSerializer.Deserialize (System.Xml.Serialization.XmlSerializationReader reader) [0x00000] in <filename unknown>:0
    19.   at System.Xml.Serialization.XmlNodeEventHandler.EndInvoke (IAsyncResult result) [0x00000] in <filename unknown>:0
    20.   at System.Xml.Serialization.XmlSerializer.Deserialize (System.Xml.XmlReader xmlReader) [0x00000] in <filename unknown>:0
    21.   at FormationLoader.readFormationXML () [0x00000] in <filename unknown>:0
    22.   at testLoad.Start () [0x00000] in <filename unknown>:0
    23.   at Replacements.RemotingServices.CreateClientProxy (System.Type objectType, System.String url, System.Object[] activationAttributes) [0x00000] in <filename unknown>:0
    24. Replacements.RemotingServices:CreateClientProxy(Type, String, Object[])
    25. (Filename: currently not available on il2cpp Line: -1)
     
  3. Jodacola

    Jodacola

    Joined:
    Dec 29, 2012
    Posts:
    2
    I had been beating my head against this since Unity 5 was released. An XML definition in my project had a List<T> member in it that was causing deserialization to fail. Instead of waiting for a fix, I opted to, instead, change all List<T> types to arrays (e.g. List<Item> -> Item[]). My deserializations worked as expected, afterward.

    While this isn't a fix, it's a viable workaround if you have access to the source throwing the exception, and you need to get past it quickly (mine was a time-sensitive matter, hence determining the work-around instead of waiting on a fix).
     
    idunlop_oefun likes this.
  4. idunlop_oefun

    idunlop_oefun

    Joined:
    Aug 31, 2010
    Posts:
    240
    Thanks for that. I'll give that a try. FWIW, the issue goes away if I compile with the .Net 2.0 Subset option. i.e. it only breaks when using .Net 2.0 Full
     
  5. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,747
    This is a know issue with the IL2CPP scripting backend. It does not support Type.MakeGenericType unless the type is explicitly used in your code, and therefore available for the AOT compiler pass.

    The System.Reflection.MonoProperty+Getter`2 type is internal in mscorlib.dll though, so you unfortunately cannot use it in your code. We're working on full support for MakeGenericType, but it is not quite ready yet.

    The .NET 2.0 Subset uses a more AOT-friendly code path through mscorlib.dll, and the code that calls MakeGenericType is actually not called, so this problem does not occur. Until we complete support for MakeGenericType though, I don't believe this will work with the .NET 2.0 profile.
     
    idunlop_oefun likes this.
  6. idunlop_oefun

    idunlop_oefun

    Joined:
    Aug 31, 2010
    Posts:
    240
  7. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,747
  8. idunlop_oefun

    idunlop_oefun

    Joined:
    Aug 31, 2010
    Posts:
    240
    @JoshPeterson Inevitable follow up question; when do you think this will be available in 5.0?
     
  9. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,747
    @idunlop_oefun

    Sorry, I missed in the earlier part of the discussing that you are using 5.0. This missed should be available in 5.0.0p3, which is scheduled to be out next Wednesday. Of course, that schedule can slip, but that is our plan.
     
    idunlop_oefun likes this.