我有一个Xamarin.iOS应用程序。我正在引用一个iOS库项目。在图书馆项目中,我有一个非常简单的课程。
using System;
namespace Noodle.iOS
{
public class TestClass
{
string property;
public TestClass (string property)
{
this.property = property;
}
public string Property
{
get
{
return property;
}
}
}
}
当尝试在AppDelegate中实例化此类时,我收到以下错误。
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
我正在使用此代码在AppDelegate中实例化该类。
var testClass = new Noodle.iOS.TestClass("test");
我已提到错误消息中提到的“限制”,但未找到与我的设置有关的任何内容。我没有使用泛型/虚拟。我也在联系一切。
为什么我会收到此错误的任何想法?为什么MonoTouch(或mtouch.exe)不能AOT编译我引用的iOS库项目?
另一方面,有没有办法在iOS模拟器中禁用JIT,使其更像设备?
更新
看起来,它与我的其他项目中的其他方法/类有关。似乎有一种用法会导致整个库崩溃。如果我不使用这个特定的静态类,我可以正确使用整个库。
Noodle.Engine.Singleton<Noodle.TinyIoCContainer>.Instance = new Noodle.TinyIoCContainer();
// var current = Noodle.EngineContext.Current;
上面的代码有效。容器被创建。但是,如果我取消注释SECOND线,FIRST线将不会给我这些 - 只有错误。
有什么想法吗? “Current”属性应该只返回我在第一行创建的单例实例。
这是github上的EngineContext.cs文件,以帮助确定原因。
https://github.com/theonlylawislove/Noodle/blob/master/Source/Noodle/EngineContext.cs