1

I have a Xamarin.iOS application. I am referencing an iOS Library project. In the library project, I have a very simple class.

using System;

namespace Noodle.iOS
{
    public class TestClass
    {
        string property;

        public TestClass (string property)
        {
            this.property = property;
        }

        public string Property
        {
            get
            {
                return property;
            }
        }

    }
}

When trying to instantiate this class in the AppDelegate, I got the following error.

System.ExecutionEngineException: Attempting to JIT compile method 'Noodle.iOS.TestClass:.ctor (string)' while running with --aot-only. See http://docs.xamarin.com/ios/about/limitations for more information

I am using this code to instantiate the class in the AppDelegate.

var testClass = new Noodle.iOS.TestClass("test");

I have refered to the "limitations" mentioned in the error message, but didn't find anything that relates to my setup. I am not using generics/virtuals. I am also linking everything.

Any ideas why I would get this error? Why would MonoTouch (or mtouch.exe) not AOT-compile my referenced iOS Library project?

On a side not, is there a way to disable JIT in the iOS simulator to behave more like a device?

UPDATE

It seems, it has to do with other methods/classes in my other project. It seems that there is one usage that causes the entire library to break. I could use the entire library correct if I don't use this particular static class.

Noodle.Engine.Singleton<Noodle.TinyIoCContainer>.Instance = new Noodle.TinyIoCContainer();
// var current = Noodle.EngineContext.Current;

The code above works. The container gets created. However, if I uncomment the SECOND line, the FIRST line will not give me these --aot-only errors.

Any ideas? The "Current" property should just return my the singleton instance created on the first line.

Here is the EngineContext.cs file on github to help determine the cause.

https://github.com/theonlylawislove/Noodle/blob/master/Source/Noodle/EngineContext.cs

Paul Knopf
  • 9,568
  • 23
  • 77
  • 142
  • 1
    This looks very strange. I suggest you create a complete test solution that can be used to reproduce it, because what you've shown here should work just fine. – Rolf Bjarne Kvinge Apr 01 '13 at 21:22
  • Rolf, I sent an e-mail to support (Michael James) with a link to download the project. Thanks! – Paul Knopf Apr 02 '13 at 13:03

0 Answers0