我有最新的Xamarin.iOS测试版;尝试使用任何异步方法会触发JIT异常。无论方法的内容如何都会发生。
控制器我正在运行它(主要是去除了令牌异步方法)
using System;
using System.Drawing;
using System.Net.Http;
using MonoTouch.Foundation;
using System.Collections.Generic;
using MonoTouch.UIKit;
using Archer.Base;
namespace Archer.Ios
{
public class CategoryTableViewController : UITableViewController
{
public CategoryTableViewController () : base (UITableViewStyle.Grouped)
{
}
String foo;
public override void DidReceiveMemoryWarning ()
{
// Releases the view if it doesn't have a superview.
base.DidReceiveMemoryWarning ();
// Release any cached data, images, etc that aren't in use.
}
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
//*snip*
}
public override void ViewDidAppear (bool animated)
{
LoadCategories ();
base.ViewDidAppear (animated);
}
public async void LoadCategories ()
{
foo = await (new HttpClient ()).GetStringAsync
("http://ifconfig.me/all.json");
}
}
}
System.ExecutionEngineException:尝试JIT编译方法 “System.Runtime.CompilerServices.AsyncVoidMethodBuilder:启动 (Archer.Ios.CategoryTableViewController / c__async0&)'运行时 只使用--aot。请参阅http://docs.xamarin.com/ios/about/limitations 更多信息。
at Archer.Ios.CategoryTableViewController.LoadCategories()[0x00000] in:0 at Archer.Ios.CategoryTableViewController.ViewDidLoad() [0x0009d] in /Users/apaulin/src/Archer/Archer.Ios/CategoryTableViewController.cs:43 at at(包装器管理到原生) MonoTouch.ObjCRuntime.Messaging:void_objc_msgSend(intptr,intptr)at at MonoTouch.UIKit.UIWindow.MakeKeyAndVisible()[0x00008] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIWindow.g.cs:129 at Archer.Ios.AppDelegate.FinishedLaunching (MonoTouch.UIKit.UIApplication应用程序,MonoTouch.Foundation.NSDictionary 选项)[0x00054] in /Users/apaulin/src/Archer/Archer.Ios/AppDelegate.cs:39 at at(wrapper) 托管到原生)MonoTouch.UIKit.UIApplication:UIApplicationMain (int,string [],intptr,intptr)在MonoTouch.UIKit.UIApplication.Main (System.String [] args,System.String principalClassName,System.String delegateClassName)[0x0004c] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:38 at Archer.Ios.Application.Main(System.String [] args)[0x00001] in /Users/apaulin/src/Archer/Archer.Ios/Main.cs:17
答案 0 :(得分:1)
解决:代码中的其他地方有一个麻烦的泛型方法导致JIT问题。
答案 1 :(得分:0)
尝试一些代码组合,看看是否能找到具体问题。
这是一个尝试的例子:
public async Task<string> LoadCategories ()
{
var client = new HttpClient ();
return await client.GetStringAsync("http://ifconfig.me/all.json");
}
如果您的某个组合有效,我会使用破解的示例向Xamarin's Bugzilla发布错误,然后发布您的解决方法。这将有助于Xamarin解决它。