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

I am going through 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 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. The problem encountered is 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
    {
        private 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
2. static library .a file
3. ApiDefinitions.cs
4. StructsAndEnums.cs

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

Sign In or Register to comment.