title: Xamarin.iOS "Attempting to JIT compile method" simple class
body: <p>I have a Xamarin.iOS application. I am referencing an iOS Library project. In the library project, I have a very simple class.</p>
  
  <pre><code>using System;
  
  namespace Noodle.iOS
  {
      public class TestClass
      {
          string property;
  
          public TestClass (string property)
          {
              this.property = property;
          }
  
          public string Property
          {
              get
              {
                  return property;
              }
          }
  
      }
  }
  </code></pre>
  
  <p>When trying to instantiate this class in the AppDelegate, I got the following error.</p>
  
  <pre><code>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
  </code></pre>
  
  <p>I am using this code to instantiate the class in the AppDelegate.</p>
  
  <pre><code>var testClass = new Noodle.iOS.TestClass("test");
  </code></pre>
  
  <p>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.</p>
  
  <p>Any ideas why I would get this error? Why would MonoTouch (or mtouch.exe) not AOT-compile my referenced iOS Library project?</p>
  
  <p>On a side not, is there a way to disable JIT in the iOS simulator to behave more like a device?</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>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.</p>
  
  <pre><code>Noodle.Engine.Singleton&lt;Noodle.TinyIoCContainer&gt;.Instance = new Noodle.TinyIoCContainer();
  // var current = Noodle.EngineContext.Current;
  </code></pre>
  
  <p>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.</p>
  
  <p>Any ideas? The "Current" property should just return my the singleton instance created on the first line.</p>
  
  <p>Here is the EngineContext.cs file on github to help determine the cause.</p>
  
  <p><a href="https://github.com/theonlylawislove/Noodle/blob/master/Source/Noodle/EngineContext.cs" rel="nofollow">https://github.com/theonlylawislove/Noodle/blob/master/Source/Noodle/EngineContext.cs</a></p>