System.ExecutionEngineException "Attempting to JIT compile method" on Physical Device, iPod Touch

The iOS application errors when run on a physical iOS device, iPod Touch, in debug mode. The project runs fine in the simulator in both debug/release modes and also when the application is deployed to a physical iPod Touch. A provisioning profile has been created for the iOS application.

I am following the instructions, "Walkthrough: Binding an iOS Objective-C Library", on the Xamarin website https://developer.xamarin.com/guides/ios/advanced_topics/binding_objective-c/walkthrough/. The project creates an objective-c binding library for InfColorPicker and uses the control in an iOS application.

The application errors when attempting to debug the application on the physical device from the IDE. The application launches then when the button is selected to open the InfColorPickerController the following error occurs

System.ExecutionEngineException has been thrown

Attempting to JIT compile method 'InfColorPicker.InfColorPickerController:set_WeakDelegate (Foundation.NSObject)' while running in aot-only mode. See https://developer.xamarin.com/guides/ios/advanced_topics/limitations/ for more information.

The error occurs after calling HandleTouchUpInsideWithStrongDelegate in the ViewController Class on the assignment "picker.Delegate = selector;". The exception is thrown when the InfColorPickerControllerDelegate is set in the InfColorPickerController class. Both of the classes are below.

namespace InfColorPickerSample
{
    public partial class ViewController : UIViewController
    {
        ColorSelectedDelegate selector;
        protected ViewController(IntPtr handle) : base(handle)
        {
            // Note: this .ctor should not contain any initialization logic.
        }

        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            // Perform any additional setup after loading the view, typically from a nib.
            ChangeColorButton.TouchUpInside += HandleTouchUpInsideWithStrongDelegate;
            selector = new ColorSelectedDelegate(this);
        }

        private void HandleTouchUpInsideWithStrongDelegate(object sender, EventArgs e)
        {
            InfColorPickerController picker = InfColorPickerController.ColorPickerViewController();
            picker.Delegate = selector;
            picker.PresentModallyOverViewController(this);
        }
    }
}


namespace InfColorPicker { 
    [Register("InfColorPickerController", true)] 
    public unsafe partial class InfColorPickerController : global::UIKit.UIViewController { 
        [CompilerGenerated] 
        public InfColorPickerControllerDelegate Delegate { 
            get { 
                return WeakDelegate as InfColorPickerControllerDelegate; 
            } 
            set { 
                WeakDelegate = value; 
            } 
        } 
    } 
} 

I've tried the following and still have the same problem
1. Built the binding and iOS project in Visual Studio 2015 Professional - PC
2. Built the binding and iOS project in Xamarin Studio Community 6.3.864 - MAC
3. Built the binding and iOS project in Visual Studio 2017 Community - MAC
4. Used the static library .a file, ApiDefinitions.cs, StructsAndEnums from the example project on https://developer.xamarin.com/samples/monotouch/InfColorPicker
5. Changed "Linker behavior" to "Don't Link"

The odd part is that when the example project from the xamarin webpage, https://developer.xamarin.com/samples/monotouch/InfColorPicker, it runs on the physical device without any problems.

The project runs and functions normally on a physical device even through the following files are replaced
1. static library .a file
2. ApiDefinitions.cs
3. StructsAndEnums.cs

How do I resolve this problem? I've been pulling out my hair for the past week trying to resolve this problem.

Best Answer

  • SONGKE01_telaforceSONGKE01_telaforce USMember ✭✭
    Accepted Answer

    A setting in the IDE was causing this error to occur.

    To fix this problem make the following changes. In the binding project, the checkbox for "Enable Optimizations" must be enabled for the Configuration "Debug" as shown in the image below.

Answers

  • SONGKE01_telaforceSONGKE01_telaforce USMember ✭✭
    Accepted Answer

    A setting in the IDE was causing this error to occur.

    To fix this problem make the following changes. In the binding project, the checkbox for "Enable Optimizations" must be enabled for the Configuration "Debug" as shown in the image below.

  • DirkWeltzDirkWeltz DEMember ✭✭✭

    Super! Thank you for sharing this info. Helps me a lot.

  • RoySadakaRoySadaka USMember ✭✭
    edited September 16

    @SONGKE01_telaforce @DirkWeltz
    Hey,
    I have a .Net Standart 1.6.1 project on VisualStudio Community for Mac and once ive installed the Nuget package "Rebex.Elliptic.Curve25519" i get the same error as you described (running in iPhone 6)

    System.ExecutionEngineException
    Attempting to JIT compile method '########' while running in aot-only mode. See https://developer.xamarin.com/guides/ios/advanced_topics/limitations/ for more information.

    Ive enabled "Enable Optimizations" on all of the projects, like yo suggested, but the error persist.

    Any idea how to handle it?

    If any addition information is needed please share and i will post asap.

    thank you in advance.
    Roy.

Sign In or Register to comment.