Code crashes in .Net Standard Library but works in a Shared Project. (ExecutionEngineException)

AlexAlex USMember ✭✭

I have updated some of our core projects from Shared Projects to .NET Standard 2.0 libraries. These are to be shared between Android, iOS and server. After the migration, Android now seems to work just as before. Nice! But on iOS I am are getting constant crashes with the follow exception:

System.ExecutionEngineException
Attempting to JIT compile method 'System.Func5<StandardLibrary.MethodInvokerEventHandler3<System.EventHandler1<System.EventArgs>, object, System.EventArgs>, System.EventHandler1<System.EventArgs>, object, System.EventArgs, bool>:BeginInvoke (StandardLibrary.MethodInvokerEventHandler3<System.EventHandler1<System.EventArgs>, object, System.EventArgs>,System.EventHandler`1<System.EventArgs>,object,System.EventArgs,System.AsyncCallback,object)' while running in aot-only mode. See docs.microsoft.com/xamarin/ios/internals/limitations for more information.

It seems like the code is compiled differently when it is part of the iOS project but when it is part of .NET Standard project it cannot be fully compile AOT. The same type of code works on Android, server, and even iOS Simulator. Based on the linked documentation it does seem like we are running into the documented limitations. But the documentation seems to state these are just iOS limitations in general, so we should have had seen the same issues before when using Shared Projects.

I tried playing around with some project settings such as Linker behavior to match the simulator. But nothing works.

The core code in question has been used for years and is integrated in many projects, including other shared libraries. It is part of a large set of classes around delegates, threading and event handling.

Attached is a small sample project that can reproduce one of the crashes. In the sample project all the files in the .NET Standard project are duplicated within the iOS project. When referencing the files in the iOS project, everything works. When referencing the standard library files, it crashes.

This is completely blocking us from using .NET Standard. Any help would be appreciated.

Answers

  • LucasZhangLucasZhang Member, Xamarin Team Xamurai

    Does it crash only on iOS real device?

  • AlexAlex USMember ✭✭
    edited May 2019

    Yes, everything works fine on the simulator. It only crashes on a real iOS device.

Sign In or Register to comment.