Unity 5.0.3f2 il2cpp problem: Attempting to call method 'System.Reflection.MonoProperty::GetterAdapt

I updated yesterday to 5.0.3 in the hopes this would fix all my code generation problems with 5.0.1. Thankfully it DID fix most of them, but this one still remains.

I believe the problem is occurring due to XML serialization of a pretty complicated object hierarchy including lists. The call stack is confusing, though, in that it mentions some methods that have NOTHING to do with that call stack. (references to Vuforia and LEMediatorVisualConsole)

I guess I’m going to try to replace one list which was being complained about in 5.0.1 with an array or a non-generic List and see what happens, I guess…

System.ExecutionEngineException: Attempting to call method ‘System.Reflection.MonoProperty::GetterAdapterFrame’ for which no ahead of time (AOT) code was generated.

Stack trace of the exception:
at System.Reflection.EventInfo+AddEventAdapter.Invoke (System.Object _this, System.Delegate dele) [0x00000] in :0
at System.Reflection.MonoProperty+GetterAdapter.Invoke (System.Object _this) [0x00000] in :0
at Vuforia.SurfaceBehaviour…ctor () [0x00000] in :0
at System.Reflection.MonoProperty.GetValue (System.Object obj, System.Object[ ] index) [0x00000] in :0
at Vuforia.SurfaceBehaviour…ctor () [0x00000] in :0
at System.Xml.Serialization.XmlSerializationWriterInterpreter.WriteListContent (System.Object container, System.Xml.Serialization.TypeData listType, System.Xml.Serialization.ListMap map, System.Object ob, System.Text.StringBuilder targetString) [0x00000] in :0
at System.Xml.Serialization.XmlSerializationWriterInterpreter.WriteMemberElement (System.Xml.Serialization.XmlTypeMapElementInfo elem, System.Object memberValue) [0x00000] in :0
at System.Xml.Serialization.XmlSerializationWriterInterpreter.WriteElementMembers (System.Xml.Serialization.ClassMap map, System.Object ob, Boolean isValueList) [0x00000] in :0
at System.Xml.Serialization.XmlSerializationWriterInterpreter.WriteObjectElementElements (System.Xml.Serialization.XmlTypeMapping typeMap, System.Object ob) [0x00000] in :0
at System.Xml.Serialization.XmlNodeEventHandler.EndInvoke (IAsyncResult result) [0x00000] in :0
at System.Xml.Serialization.XmlSerializationWriterInterpreter.WriteObjectElement (System.Xml.Serialization.XmlTypeMapping typeMap, System.Object ob, System.String element, System.String namesp) [0x00000] in :0
at System.Xml.Serialization.XmlNodeEventHandler.EndInvoke (IAsyncResult result) [0x00000] in :0
at System.Xml.Serialization.XmlSerializationWriterInterpreter.WriteObject (System.Xml.Serialization.XmlTypeMapping typeMap, System.Object ob, System.String element, System.String namesp, Boolean isNullable, Boolean needType, Boolean writeWrappingElem) [0x00000] in :0
at System.Xml.Serialization.XmlNodeEventHandler.EndInvoke (IAsyncResult result) [0x00000] in :0
at System.Xml.Serialization.XmlSerializationWriterInterpreter.WriteMemberElement (System.Xml.Serialization.XmlTypeMapElementInfo elem, System.Object memberValue) [0x00000] in :0
at System.Xml.Serialization.XmlSerializationWriterInterpreter.WriteElementMembers (System.Xml.Serialization.ClassMap map, System.Object ob, Boolean isValueList) [0x00000] in :0
at System.Xml.Serialization.XmlSerializationWriterInterpreter.WriteObjectElementElements (System.Xml.Serialization.XmlTypeMapping typeMap, System.Object ob) [0x00000] in :0
at System.Xml.Serialization.XmlNodeEventHandler.EndInvoke (IAsyncResult result) [0x00000] in :0
at System.Xml.Serialization.XmlSerializationWriterInterpreter.WriteObjectElement (System.Xml.Serialization.XmlTypeMapping typeMap, System.Object ob, System.String element, System.String namesp) [0x00000] in :0
at System.Xml.Serialization.XmlNodeEventHandler.EndInvoke (IAsyncResult result) [0x00000] in :0
at System.Xml.Serialization.XmlSerializationWriterInterpreter.WriteObject (System.Xml.Serialization.XmlTypeMapping typeMap, System.Object ob, System.String element, System.String namesp, Boolean isNullable, Boolean needType, Boolean writeWrappingElem) [0x00000] in :0
at System.Xml.Serialization.XmlNodeEventHandler.EndInvoke (IAsyncResult result) [0x00000] in :0
at System.Xml.Serialization.XmlSerializationWriterInterpreter.WriteMemberElement (System.Xml.Serialization.XmlTypeMapElementInfo elem, System.Object memberValue) [0x00000] in :0
at System.Xml.Serialization.XmlSerializationWriterInterpreter.WriteElementMembers (System.Xml.Serialization.ClassMap map, System.Object ob, Boolean isValueList) [0x00000] in :0
at System.Xml.Serialization.XmlSerializationWriterInterpreter.WriteObjectElementElements (System.Xml.Serialization.XmlTypeMapping typeMap, System.Object ob) [0x00000] in :0
at System.Xml.Serialization.XmlNodeEventHandler.EndInvoke (IAsyncResult result) [0x00000] in :0
at System.Xml.Serialization.XmlSerializationWriterInterpreter.WriteObjectElement (System.Xml.Serialization.XmlTypeMapping typeMap, System.Object ob, System.String element, System.String namesp) [0x00000] in :0
at System.Xml.Serialization.XmlNodeEventHandler.EndInvoke (IAsyncResult result) [0x00000] in :0
at System.Xml.Serialization.XmlSerializationWriterInterpreter.WriteObject (System.Xml.Serialization.XmlTypeMapping typeMap, System.Object ob, System.String element, System.String namesp, Boolean isNullable, Boolean needType, Boolean writeWrappingElem) [0x00000] in :0
at System.Xml.Serialization.XmlNodeEventHandler.EndInvoke (IAsyncResult result) [0x00000] in :0
at System.Xml.Serialization.XmlSerializationWriterInterpreter.WriteRoot (System.Object ob) [0x00000] in :0
at System.Xml.Serialization.XmlSerializer.Serialize (System.Object o, System.Xml.Serialization.XmlSerializationWriter writer) [0x00000] in :0
at System.Xml.Serialization.XmlNodeEventHandler.EndInvoke (IAsyncResult result) [0x00000] in :0
at System.Xml.Serialization.XmlSerializer.Serialize (System.Xml.XmlWriter writer, System.Object o, System.Xml.Serialization.XmlSerializerNamespaces namespaces) [0x00000] in :0
at System.Xml.Serialization.XmlSerializer.Serialize (System.Xml.XmlWriter xmlWriter, System.Object o) [0x00000] in :0
at liveadz.liveadzenterprise.storage.impl.LEStorage.SerializeObject (System.Object pObject) [0x00000] in :0
at LEMediatorVisualConsole.OnRemove () [0x00000] in :0
at liveadz.liveadzenterprise.controller.LECommandStart.InitAppPrefs () [0x00000] in :0

Ok, so I gather now that the problem I have is to do with just trying to serialize a property rather than anything to do with a list.

1 Like

Can anyone throw light on what this problem means? I’ve been trying to remove elements from XML Serialization to isolate what the problem is, but my testing results don’t make any sense.

I think something with AOT got broken recently. You could try switching to IL2CPP (which you need to do to submit to the App Store anyway).

Thanks for the response, ladron!

The above was with IL2CPP, actually.

I finally wisened up and made a test project just to test serialization. Class2 just has an int in it, Class1 has a list of Class2’s.

This will serialize if I am using the 2.0 subset, whether with Mono or IL2CPP. If I have full 2.0 selected, though, it dies. Which is counter-intuitive to me…

And I think I’m currently using a plugin whose latest version requires 2.0. :frowning:

The System.Reflection.MonoProperty+GetterAdapter type is not AOT friendly, for either Mono or IL2CPP. This works with the .NET 2.0 Subset profile because the version of mscorlib.dll with that profile takes a different code path which doe snot use the System.Reflection.MonoProperty+GetterAdapter type.

Is it correct that this problems happens with both Mono and IL2CPP using the .NET 2.0 profile? If not, then we have an IL2CPP-specific bug to correct. Thanks.

@JoshPeterson This problem occurs with both Mono and IL2CPP.

@ccklokwerks

Ok, so we can look at this as a general AOT bug, but since with works with .NET 2.0 Subset, I doubt that it will be high priority. Is there a specific reason you need to use .NET 2.0, or are you content to use .NET 2.0 Subset?

I reviewed previous versions of my project and found that the reason this was all working before was that I was using the .Net 2.0 Subset. But one of the plugins I’m using now requires .Net 2.0.

I’m implementing a new super-simple list class with no (serialized) properties, to replace my use of List in xml-serialized classes.

Chris

I have a similar issue with .GetValue()

  • Unity 4.6.6p3
  • IL2CPP
  • .NET 2.0
  • Universal architecture

I can’t fix this by switching to the subset because then I can’t even build the project.

@CoalCzar

Does this same issue happen with the Mono scripting backend? I would expect it too, but we might have an IL2CPP specific bug here which we would need to investigate.

I believe it also happens with .NET 2.0 (but definitely not with the .NET 2.0 subset) when building with Mono backend.

@CoalCzar

Ok, thanks. This makes sense, at least. So we need to sort out the problem with .NET 2.0 Subset and IL2CPP then (on the other thread).

Any news with this issue?

@DarkPixel

Based on the other thread mentioned above (http://forum.unity3d.com/threads/please-help-for-il2cpp-problem.302670), I think the work around was to use the .NET 2.0 profile.

I have the opposite problem with WebGL. I have the error in .NET 2.0 but not in .NET 2.0 Subset, I’ll file a bug.

@DarkPixel

Thanks, we will investigate then.

Hi, I have the same issue as the threadstarter, I’m getting

ExecutionEngineException: Attempting to call method ‘System.Reflection.MonoProperty::GetterAdapterFrame’ for which no ahead of time (AOT) code was generated.

when runnning on IOS, with .NET 2.0 as Api compatibility level. Using Unity 5.2.1f1.

I’m forced to .Net 2.0 profile due to a plugin requiring it. I’ve tried using both IL2CPP and Mono as scripting backend but with the same result. Also tried different settings for strip enabling and level. When removing the plugin and reverting to .NET2.0 subset everything works. But unfortunately the plugin is needed.

In a previous post Josh stated:
The System.Reflection.MonoProperty+GetterAdapter type is not AOT friendly, for either Mono or IL2CPP. This works with the .NET 2.0 Subset profile because the version of mscorlib.dll with that profile takes a different code path which doe snot use the System.Reflection.MonoProperty+GetterAdapter type.

Does that mean that there is no fix or workaround for this issue?

@PeterDe

Unfortunately we don’t have a good solution for this case. The problem is in the C# standard library code from the version of Mono we use, so it is possible to change. However, the AOT-unfriendly code path is nice for JIT platforms.

I would recommend two courses of action:

  1. Check with the plugin maintainer (if possible) to see if they can make a version that works with .NET 2.0 subset
  2. Submit a bug report with Unity (including an example project), and let me know the bug report number.

I think that one of these two paths should work. Based on my experience with this issue in the past, I suspect the plugin maintainer route might be quicker, as I know the changes to the standard libraries on the Unity side will not be simple.

I filed a bug (737529) the 19th but I still haven’t received an answer.
Our project really depend of OnPropertyChanged so if it’s not fixable, we will need to use a workaround.
Thanks!