Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

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

Discussion in 'iOS and tvOS' started by ccklokwerks, Jun 10, 2015.

  1. ccklokwerks

    ccklokwerks

    Joined:
    Oct 21, 2014
    Posts:
    62
    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 <filename unknown>:0
    at System.Reflection.MonoProperty+GetterAdapter.Invoke (System.Object _this) [0x00000] in <filename unknown>:0
    at Vuforia.SurfaceBehaviour..ctor () [0x00000] in <filename unknown>:0
    at System.Reflection.MonoProperty.GetValue (System.Object obj, System.Object[] index) [0x00000] in <filename unknown>:0
    at Vuforia.SurfaceBehaviour..ctor () [0x00000] in <filename unknown>: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 <filename unknown>:0
    at System.Xml.Serialization.XmlSerializationWriterInterpreter.WriteMemberElement (System.Xml.Serialization.XmlTypeMapElementInfo elem, System.Object memberValue) [0x00000] in <filename unknown>:0
    at System.Xml.Serialization.XmlSerializationWriterInterpreter.WriteElementMembers (System.Xml.Serialization.ClassMap map, System.Object ob, Boolean isValueList) [0x00000] in <filename unknown>:0
    at System.Xml.Serialization.XmlSerializationWriterInterpreter.WriteObjectElementElements (System.Xml.Serialization.XmlTypeMapping typeMap, System.Object ob) [0x00000] in <filename unknown>:0
    at System.Xml.Serialization.XmlNodeEventHandler.EndInvoke (IAsyncResult result) [0x00000] in <filename unknown>:0
    at System.Xml.Serialization.XmlSerializationWriterInterpreter.WriteObjectElement (System.Xml.Serialization.XmlTypeMapping typeMap, System.Object ob, System.String element, System.String namesp) [0x00000] in <filename unknown>:0
    at System.Xml.Serialization.XmlNodeEventHandler.EndInvoke (IAsyncResult result) [0x00000] in <filename unknown>: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 <filename unknown>:0
    at System.Xml.Serialization.XmlNodeEventHandler.EndInvoke (IAsyncResult result) [0x00000] in <filename unknown>:0
    at System.Xml.Serialization.XmlSerializationWriterInterpreter.WriteMemberElement (System.Xml.Serialization.XmlTypeMapElementInfo elem, System.Object memberValue) [0x00000] in <filename unknown>:0
    at System.Xml.Serialization.XmlSerializationWriterInterpreter.WriteElementMembers (System.Xml.Serialization.ClassMap map, System.Object ob, Boolean isValueList) [0x00000] in <filename unknown>:0
    at System.Xml.Serialization.XmlSerializationWriterInterpreter.WriteObjectElementElements (System.Xml.Serialization.XmlTypeMapping typeMap, System.Object ob) [0x00000] in <filename unknown>:0
    at System.Xml.Serialization.XmlNodeEventHandler.EndInvoke (IAsyncResult result) [0x00000] in <filename unknown>:0
    at System.Xml.Serialization.XmlSerializationWriterInterpreter.WriteObjectElement (System.Xml.Serialization.XmlTypeMapping typeMap, System.Object ob, System.String element, System.String namesp) [0x00000] in <filename unknown>:0
    at System.Xml.Serialization.XmlNodeEventHandler.EndInvoke (IAsyncResult result) [0x00000] in <filename unknown>: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 <filename unknown>:0
    at System.Xml.Serialization.XmlNodeEventHandler.EndInvoke (IAsyncResult result) [0x00000] in <filename unknown>:0
    at System.Xml.Serialization.XmlSerializationWriterInterpreter.WriteMemberElement (System.Xml.Serialization.XmlTypeMapElementInfo elem, System.Object memberValue) [0x00000] in <filename unknown>:0
    at System.Xml.Serialization.XmlSerializationWriterInterpreter.WriteElementMembers (System.Xml.Serialization.ClassMap map, System.Object ob, Boolean isValueList) [0x00000] in <filename unknown>:0
    at System.Xml.Serialization.XmlSerializationWriterInterpreter.WriteObjectElementElements (System.Xml.Serialization.XmlTypeMapping typeMap, System.Object ob) [0x00000] in <filename unknown>:0
    at System.Xml.Serialization.XmlNodeEventHandler.EndInvoke (IAsyncResult result) [0x00000] in <filename unknown>:0
    at System.Xml.Serialization.XmlSerializationWriterInterpreter.WriteObjectElement (System.Xml.Serialization.XmlTypeMapping typeMap, System.Object ob, System.String element, System.String namesp) [0x00000] in <filename unknown>:0
    at System.Xml.Serialization.XmlNodeEventHandler.EndInvoke (IAsyncResult result) [0x00000] in <filename unknown>: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 <filename unknown>:0
    at System.Xml.Serialization.XmlNodeEventHandler.EndInvoke (IAsyncResult result) [0x00000] in <filename unknown>:0
    at System.Xml.Serialization.XmlSerializationWriterInterpreter.WriteRoot (System.Object ob) [0x00000] in <filename unknown>:0
    at System.Xml.Serialization.XmlSerializer.Serialize (System.Object o, System.Xml.Serialization.XmlSerializationWriter writer) [0x00000] in <filename unknown>:0
    at System.Xml.Serialization.XmlNodeEventHandler.EndInvoke (IAsyncResult result) [0x00000] in <filename unknown>:0
    at System.Xml.Serialization.XmlSerializer.Serialize (System.Xml.XmlWriter writer, System.Object o, System.Xml.Serialization.XmlSerializerNamespaces namespaces) [0x00000] in <filename unknown>:0
    at System.Xml.Serialization.XmlSerializer.Serialize (System.Xml.XmlWriter xmlWriter, System.Object o) [0x00000] in <filename unknown>:0
    at liveadz.liveadzenterprise.storage.impl.LEStorage.SerializeObject (System.Object pObject) [0x00000] in <filename unknown>:0
    at LEMediatorVisualConsole.OnRemove () [0x00000] in <filename unknown>:0
    at liveadz.liveadzenterprise.controller.LECommandStart.InitAppPrefs () [0x00000] in <filename unknown>:0
     
  2. ccklokwerks

    ccklokwerks

    Joined:
    Oct 21, 2014
    Posts:
    62
    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.
     
    Ruslank100 likes this.
  3. ccklokwerks

    ccklokwerks

    Joined:
    Oct 21, 2014
    Posts:
    62
    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.
     
  4. ladron

    ladron

    Joined:
    Mar 16, 2012
    Posts:
    47
    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).
     
  5. ccklokwerks

    ccklokwerks

    Joined:
    Oct 21, 2014
    Posts:
    62
    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. :(
     
  6. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,920
    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.
     
  7. ccklokwerks

    ccklokwerks

    Joined:
    Oct 21, 2014
    Posts:
    62
    @JoshPeterson This problem occurs with both Mono and IL2CPP.
     
  8. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,920
    @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?
     
  9. ccklokwerks

    ccklokwerks

    Joined:
    Oct 21, 2014
    Posts:
    62
    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
     
  10. CoalCzar

    CoalCzar

    Joined:
    Nov 25, 2012
    Posts:
    22
    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.

     
  11. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,920
    @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.
     
  12. CoalCzar

    CoalCzar

    Joined:
    Nov 25, 2012
    Posts:
    22
    I believe it also happens with .NET 2.0 (but definitely not with the .NET 2.0 subset) when building with Mono backend.
     
  13. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,920
    @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).
     
  14. DarkPixel

    DarkPixel

    Joined:
    Sep 13, 2013
    Posts:
    79
    Any news with this issue?
     
  15. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,920
  16. DarkPixel

    DarkPixel

    Joined:
    Sep 13, 2013
    Posts:
    79
  17. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,920
    @DarkPixel

    Thanks, we will investigate then.
     
  18. PeterDe

    PeterDe

    Joined:
    Oct 20, 2015
    Posts:
    1
    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?
     
    Last edited: Oct 26, 2015
  19. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,920
    @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.
     
  20. DarkPixel

    DarkPixel

    Joined:
    Sep 13, 2013
    Posts:
    79
    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!
     
  21. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,920
    @DarkPixel

    I'll ping our QA team to have a look at this one.
     
  22. DarkPixel

    DarkPixel

    Joined:
    Sep 13, 2013
    Posts:
    79
    Thanks! They reproduced the problem.
     
  23. Artur_at_Artcode

    Artur_at_Artcode

    Joined:
    Jul 17, 2013
    Posts:
    2
    From my perspective bug (737529) is a major issue.

    Currently Unity.Newtonsof.Json doesn't compile with .NET 2.0 Subset. At the same time, with .NET 2.0, you get the described execution engine exception when make an HttpWebRequest to an HTTPS URI.

    Literally at the moment you can't have both Json.net and use https.

    @JoshPeterson can this be prioritized for the next patch release?
     
  24. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,920
    @Artur_at_Artcode

    I'll see what I can do about this bug. It is not trivial to correct, but it should be something we can handle. I can't promise a fix in the next patch release, but we can have a look at it soon.
     
  25. Artur_at_Artcode

    Artur_at_Artcode

    Joined:
    Jul 17, 2013
    Posts:
    2
    @JoshPeterson Thanks! Looking forward to your updates.
    It's a blocker and the sooner the better for us. Cheers!
     
  26. mrm83

    mrm83

    Joined:
    Nov 29, 2014
    Posts:
    345
    Any updates on this bug?
     
  27. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,920
    @mrm83

    Yes. We were able to correct this issue. The fix first appeared in 5.2.4f1.
     
  28. LeoGig-Farofa

    LeoGig-Farofa

    Joined:
    Jan 26, 2016
    Posts:
    4
    I am sorry, but the problem isn't exactly fixed. A workaround is not a fix.
    The current workaround only work for projects that don't rely on some libraries and methods, which aren't present in .NET 2.0 Subset.

    Even tho most of those are easily replaceable, when you are using plugins and assets you have no knowledge of, or when you are an unskilled programmer, this becomes a huge obstacle you will hardly surpass.

    And even if you do have the knowledge, you'll have to either substitute your plugin or rewrite it yourself. We can all imagine why this could be a huge pain.

    The problem about treating this as a fix is the mindset it generates. If something is fixed, there's no reason to change it. But viewing it as a workaround means you know you'll have to fix it later.
     
    Last edited: Jan 26, 2016
  29. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,920
    @LeoGig-Farofa

    As of 5.2.4f1, this issue should not happen with either the .NET 2.0 profile or the .NET 2.0 Subset profile. So the previous advice to work around it by using the .NET 2.0 Subset profile is no longer valid. Are you still seeing this issue occur after 5.2.4f1? If so, we may have missed a case.
     
  30. LeoGig-Farofa

    LeoGig-Farofa

    Joined:
    Jan 26, 2016
    Posts:
    4
    Yes, pretty much. I am using 5.3.1f1 and the bug still occurs.
    Before I found this topic I was running in 5.2.3.
    I am installing 5.2.4f1 atm.

    There is a thread abortion error in the middle of the report, which should be ignored, since it was already fixed.

    Here is the Xcode report:
    Code (CSharp):
    1. Error: SendFailure (Attempting to call method 'System.Reflection.MonoProperty::GetterAdapterFrame' for which no ahead of time (AOT) code was generated.)
    2.  
    3.   at System.Net.FtpDataStream.System.IDisposable.Dispose () [0x00000] in <filename unknown>:0
    4.   at System.Net.HttpWebRequest.EndGetResponse (IAsyncResult asyncResult) [0x00000] in <filename unknown>:0
    5.   at System.Net.HttpWebRequest.GetResponse () [0x00000] in <filename unknown>:0
    6.   at WebService.GetFile (System.String url, System.String& exceptionHolder) [0x00000] in <filename unknown>:0
    7.   at WebService.DownloadPhoto (System.String url, System.String& errorHandler) [0x00000] in <filename unknown>:0
    8.   at Student.DownloadPhoto () [0x00000] in <filename unknown>:0
    9.   at SynchronizerInternal.WSDownloadThread`1[T].Process () [0x00000] in <filename unknown>:0
    10.  
    11. Attempting to call method 'System.Reflection.MonoProperty::GetterAdapterFrame' for which no ahead of time (AOT) code was generated.
    12.  
    13.   at System.Reflection.MonoProperty+GetterAdapter.Invoke (System.Object _this) [0x00000] in <filename unknown>:0
    14.   at System.Reflection.MonoProperty.GetValue (System.Object obj, System.Object[] index) [0x00000] in <filename unknown>:0
    15.   at System.Net.WebConnection.Write (System.Net.HttpWebRequest request, System.Byte[] buffer, Int32 offset, Int32 size, System.String& err_msg) [0x00000] in <filename unknown>:0
    16.   at System.Net.WebConnectionStream.WriteHeaders () [0x00000] in <filename unknown>:0
    17.   at System.Net.WebConnectionStream.SetHeaders (System.Byte[] buffer) [0x00000] in <filename unknown>:0
    18.   at System.Net.HttpWebRequest.SendRequestHeaders (Boolean propagate_error) [0x00000] in <filename unknown>:0
    19.   at System.Net.HttpWebRequest.SetWriteStream (System.Net.WebConnectionStream stream) [0x00000] in <filename unknown>:0
    20. (Filename: /Users/builduser/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 37)
    21.  
    22. NotSupportedException: /Users/builduser/buildslave/unity/build/Tools/il2cpp/il2cpp/libil2cpp/icalls/mscorlib/System.Threading/Thread.cpp(368) : Unsupported internal call for IL2CPP:Thread::Abort_internal - "Thread abortion is currently not implemented on IL2CPP; it is recommended to use safer mechanisms to terminate threads."
    23.   at SynchronizerInternal.WSDownloadThread`1[T].Abort () [0x00000] in <filename unknown>:0
    24.   at SynchronizerInternal.WSDownloader.Abort (System.String message) [0x00000] in <filename unknown>:0
    25.   at SynchronizerInternal.WSDownloaderHandler.Update () [0x00000] in <filename unknown>:0
    26. (Filename: currently not available on il2cpp Line: -1)
    27.  
    28. StudentThread download failed!
    29. Error: SendFailure (Attempting to call method 'System.Reflection.MonoProperty::GetterAdapterFrame' for which no ahead of time (AOT) code was generated.)
    30.  
    31.   at System.Net.FtpDataStream.System.IDisposable.Dispose () [0x00000] in <filename unknown>:0
    32.   at System.Net.HttpWebRequest.EndGetResponse (IAsyncResult asyncResult) [0x00000] in <filename unknown>:0
    33.   at System.Net.HttpWebRequest.GetResponse () [0x00000] in <filename unknown>:0
    34.   at WebService.GetFile (System.String url, System.String& exceptionHolder) [0x00000] in <filename unknown>:0
    35.   at WebService.DownloadPhoto (System.String url, System.String& errorHandler) [0x00000] in <filename unknown>:0
    36.   at Student.DownloadPhoto () [0x00000] in <filename unknown>:0
    37.   at SynchronizerInternal.WSDownloadThread`1[T].Process () [0x00000] in <filename unknown>:0
    38.  
    39. Attempting to call method 'System.Reflection.MonoProperty::GetterAdapterFrame' for which no ahead of time (AOT) code was generated.
    40.  
    41.   at System.Reflection.MonoProperty+GetterAdapter.Invoke (System.Object _this) [0x00000] in <filename unknown>:0
    42.   at System.Reflection.MonoProperty.GetValue (System.Object obj, System.Object[] index) [0x00000] in <filename unknown>:0
    43.   at System.Net.WebConnection.Write (System.Net.HttpWebRequest request, System.Byte[] buffer, Int32 offset, Int32 size, System.String& err_msg) [0x00000] in <filename unknown>:0
    44.   at System.Net.WebConnectionStream.WriteHeaders () [0x00000] in <filename unknown>:0
    45.   at System.Net.WebConnectionStream.SetHeaders (System.Byte[] buffer) [0x00000] in <filename unknown>:0
    46.   at System.Net.HttpWebRequest.SendRequestHeaders (Boolean propagate_error) [0x00000] in <filename unknown>:0
    47.   at System.Net.HttpWebRequest.SetWriteStream (System.Net.WebConnectionStream stream) [0x00000] in <filename unknown>:0
    48. UnityEngine.Logger:Log(LogType, Object)
    49. UnityEngine.Debug:LogError(Object)
    50. SynchronizerInternal.WSDownloaderHandler:Update()
     
  31. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,920
    @LeoGig-Farofa

    Ahh, sorry, I just checked. It looks like 5.3.1f1 does not have the fix. It first appeared in the 5.3 series in 5.3.1p1. Sorry about the confusion!
     
  32. LeoGig-Farofa

    LeoGig-Farofa

    Joined:
    Jan 26, 2016
    Posts:
    4
    Oh, ok.
    I'll give it a try.
     
  33. LeoGig-Farofa

    LeoGig-Farofa

    Joined:
    Jan 26, 2016
    Posts:
    4
    @JoshPeterson

    Indeed, using 5.3.1p4 makes it disappear.
    Thank you for your support.
     
  34. Genom

    Genom

    Joined:
    Dec 2, 2014
    Posts:
    86
    Hi, I am getting this exact error when compiling to .NET 4.6 and WebGL, could you please check the unit tests about the issue # 737529 using the new compiler? I will add this also to script experimental previews feedback.

    thanks!
     
  35. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,920
    @Genom

    Indeed, this might be an issue in the new class libraries that come with .NET 4.6. They have some know problems on AOT platforms. We're working now on implementing AOT-friendly class libraries, so if you can submit a new bug report for this, I would appreciate it. We'll make sure it works.
     
  36. Genom

    Genom

    Joined:
    Dec 2, 2014
    Posts:
    86
    Hi @JoshPeterson , thanks for your answer. I have localized the top level error in the SelectMany, this is the offending line:

    Debug.Log("VMB_10");
    foreach (var action in BindingActions.Values.SelectMany(x => x))
    {
    action();
    }
    Debug.Log("VMB_11");

    Note: my mistake, it is not the SelectMany, I followed up the action() call and the offending line
    is :

    var isVisible = (bool)property.GetValue(this, null);

    where "this" is a class that inherits MonoBehaviour, I have created the bug ticket (Case 930594), I will try to modify it to add this info. Btw, once the bug is fixed, how can we get it applied to our unity 2017.1? by a patch release?


    I will open the bug in a mometn, and in the meantime I think I can work it around just with Selects, though it points to be the door to many other errors using LINQ I guess

    cheers!
     
    Last edited: Jul 13, 2017
  37. stopiccot

    stopiccot

    Joined:
    May 2, 2013
    Posts:
    26
    I'm also getting this error with after switching to Unity 2017.1 and new runtime when using https://github.com/SaladLab/Json.Net.Unity3D library. Everything was working ok using Unity 5.5 and alexzzzz C# 7.0 plugin combination. Maybe this can be workarounded with some compiler or link.xml settings?
     
  38. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,920
    @Genom

    Yes, this will likely be corrected in a 2017.1 patch release when we have the fix ready.
     
  39. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,920
    There is not a workaround in compiler or link.xml settings - this is a bug in the class libraries that we will correct. The best workaround is to try to not use code which exercises the non-AOT friendly code path.
     
  40. anton_breusov

    anton_breusov

    Joined:
    Oct 10, 2015
    Posts:
    4
    Hi!

    Regarding issue with a PropertyInfo.GetValue (Object, Object[]) call.

    By analyzing Mono sources (https://github.com/mono/mono/blob/master/mcs/class/corlib/System.Reflection/MonoProperty.cs ) we found that probably new .Net 4.6 backend used for AOT platforms is built without FULL_AOT_RUNTIME define. This probably should be fixed.

    We had issues with Unity version of JSON.Net too, and other modules (like Unity Weld, BestHTTP etc).

    Also by analyzing these sources we found a workaround for this: instead of using two-parameters call to GetValue() we used 5-parameters call, because it gets invoked inside Mono anyway for AOT builds:

    Replace:
    Code (CSharp):
    1.  
    2. propertyInfo.GetValue(object, null);
    3.  
    With a:
    Code (CSharp):
    1.  
    2. propertyInfo.GetValue(object, BindingFlags.Default, null, null, null);
    3.  
    For Newtonsoft.JSON I did this in a file (Source\Newtonsoft.Json\Utilities\ReflectionUtils.cs), then recompiled AOT versions of assemblies and put them instead of packaged versions.
     
    BBB_brunoma, Lipoly and Ges like this.
  41. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,920
    Indeed, this does correct the issue. For Unity 2017.1, we'll be shipping a patch release build which uses the AOT-friendly code path in all cases.

    In later versions of Unity (maybe 2017.2, maybe after that), we will ship an AOT-friendly profile that defines FULL_AOT_RUNTIME during compilation.
     
  42. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    Yep, this problem has reared it's ugly head again... @JoshPeterson is there something I can change in Json .NET for Unity to prevent the issue? I have a customer getting the issue on a mixed reality application. It's IL2CPP, with the .NET 4.6 profile. It uses both Json .NET and BestHTTP. For some reason, this only seems to crop up when people are also using networking of some kind. Unity version is 5.6.2p4
     
  43. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    Just an update... I was able to fix it in Json .Net for Unity. However, now seeing this error which looks like something Unity internal. Unrelated to Json .Net but I thought I'd post it.
    exception message: Attempt to access method 'Windows.Foundation.IAsyncOperation<Windows.Storage.StorageFolder>.GetResults' on type 'System.__Il2CppComObject' failed.
     
  44. invictvs1

    invictvs1

    Joined:
    Mar 7, 2014
    Posts:
    51
    The above error was actually one I received, it comes from a BestHTTP request exception when using UWP & Il2CPP.
     
    Dustin-Horne likes this.
  45. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,920
    I wasn't aware that this was in Unity 5.6 as well. We will back port the fix from 2017.1 to 5.6 - it should appear in a patch release there soon.
     
    Dustin-Horne likes this.
  46. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    Here's what's interesting. Using my AOT friendly dll that targets .net 3.5, the issue happens on 5.6. All I changed was to build Json .Net to Target .net 4.6 instead, and a couple unrelated tweaks to make it build. If you want I can PM you with the 4.6 compiled dll if it helps your internal testing.

    For what it's worth no one has reported it happening in the more popular platforms. This one happens to be uwp running on HoloLens.
     
  47. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,920
    I think the issue with Unity 5.6 is the same as in Unity 2017.1. The .NET 4.6 class libraries from Mono are not built with the AOT-friendly code paths. In Unity 5.6, the UWP and XBox One platforms can use .NET 4.6, and they use this non-AOT friendly class library code.

    So that explains why this is only happening on UWP, as that is one of two platforms which can execute this .NET 4.6 code in Unity 5.6.
     
  48. Dustin-Horne

    Dustin-Horne

    Joined:
    Apr 4, 2013
    Posts:
    4,568
    It seems weird though that recompiling my own dll to reference 4.6 instead of 3.5 fixed it though. it was more of a last ditch effort that I didn't expect to change anything.
     
  49. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,920
    Yes, that does seem odd. Maybe there is a different problem here then.
     
    Dustin-Horne likes this.
  50. Maisey

    Maisey

    Joined:
    Feb 17, 2014
    Posts:
    302
    Having this issue too trying to upgrade the project to Unity 2017.1 using experimental .NET 4.6. In this case it seems to be the FullInspector-plugin which hits the issue. Do you mind writing when there's a patch release available for testing?

    Thanks!

    Stacktrace:

    Code (CSharp):
    1. Exception caught when deserializing property <skillExtraInfo> with type <Skill>
    2. System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ExecutionEngineException: Attempting to call method 'System.Reflection.MonoProperty::GetterAdapterFrame' for which no ahead of time (AOT) code was generated.
    3.   at System.Reflection.MonoProperty+GetterAdapter.Invoke (System.Object _this) [0x00000] in <00000000000000000000000000000000>:0
    4.   at System.Reflection.MonoProperty.GetValue (System.Object obj, System.Object[] index) [0x00000] in <00000000000000000000000000000000>:0
    5.   at FullSerializer.Internal.fsMetaProperty.Read (System.Object context) [0x00000] in <00000000000000000000000000000000>:0
    6.   at FullSerializer.Internal.fsReflectedConverter.TryDeserialize (FullSerializer.fsData data, System.Object& instance, System.Type storageType) [0x00000] in <00000000000000000000000000000000>:0