1
votes

I've got the latest Xamarin.iOS beta; attempting to use any async methods triggers a JIT exception. Happens regardless of the contents of the method.

Controller I'm running it from (mostly gutted save for a token async method)

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: Attempting to JIT compile method 'System.Runtime.CompilerServices.AsyncVoidMethodBuilder:Start (Archer.Ios.CategoryTableViewController/c__async0&)' while running with --aot-only. See http://docs.xamarin.com/ios/about/limitations for more information.

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 (wrapper managed-to-native) MonoTouch.ObjCRuntime.Messaging:void_objc_msgSend (intptr,intptr) 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 app, MonoTouch.Foundation.NSDictionary options) [0x00054] in /Users/apaulin/src/Archer/Archer.Ios/AppDelegate.cs:39 at at (wrapper managed-to-native) MonoTouch.UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr) at 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

2
The Exception you posted is not enough to help you. Have you verfiied this problem exists in the current stable release? You will have to contact Xamarin if you want help with a Beta build.Security Hound
Post some of your async code to give us an idea of what's going on. I've been using the beta on a few projects and haven't run into this issue--only one place where I got an "Invalid IL" message that had an easy workaround.jonathanpeppers

2 Answers

1
votes

Solved: there was a troublesome generic method elsewhere in the code causing the JIT issue.

0
votes

Try a few combinations of your code to see if you can find the specific problem.

Here is an example to try:

        public async Task<string> LoadCategories ()
        {
            var client = new HttpClient ();

            return await client.GetStringAsync("http://ifconfig.me/all.json");
        }

If one of your combinations works, I would post a bug to Xamarin's Bugzilla with the broken example, then post your workaround, too. This will help Xamarin fix it.