Xamarin Forms on iOS JIT Failure with OnPlatform Xaml RRS feed

  • Question

  • User61518 posted

    I have an iOS app, working and running in the Apple store. I have made some changes to it, mostly converting it to a Unified API project so I can continue to submit updates, and moving a bunch of classes into either a portable class library or an iOS library (I have one of each) depending where they fit. Now when I try to run the app on the simulator, when a particular Xaml page is shown I get this exception;

    System.ExecutionEngineException: Attempting to JIT compile method 'Xamarin.Forms.OnPlatform`1:.ctor ()

    I believe this is caused by the following piece of XAML in the page being shown;

        <OnPlatform x:TypeArguments="Thickness">

    However, this Xaml is not new (it was in the app prior to my changes) and has always worked previously. I believe it should be valid (in fact I think I stole it from a Xamarin sample somewhere). I'm not really sure how to work around the problem either. I guess I can set the value in code behind but that seems ugly and unnecessary. Obviously this is only a problem on iOS due to it's limitations with JIT vs AOT compilation, new version of app works fine on WP (and in iOS simulator).

    Anyone got any ideas why this is suddenly a problem?

    This isn't the first new problem I've had like this. I had a bunch of other code using generics that used to work fine and started causing a similar error (so I rewrote the code without generics since I couldn't see another way to fix it). I've also suddenly had to mark a whole bunch of stuff with the Preserve attribute to prevent the linker from removing it (didn't have to do this previously). I put this down to the Unified API changes/today's Xamarin iOS update, but this particular problem bothers me enough to post and ask if anyone else is seeing this or has a clue what the cause is?

    Thanks. Troy

    Tuesday, February 10, 2015 12:53 AM

All replies

  • User5295 posted

    Hi Troy I am also having a similar issue where my application will crash with a 'System.ExecutionEngineException: Attempting to JIT compile method' message. The same code worked well before I updated Xamarin for Visual Studio and Xamarin Studio on my Mac build host. It seems that using the Contraints on the Relativelayouts triggers the exception, example here: pageSubMenuItemsLayout.Children.Add(pageSubMenuTitle, Constraint.Constant(AppLogoTabletWidth + AppLogoTabletMargin), Constraint.Constant(0));

    I do not know what is the cause of your sudden problem but I imagine it has a similar origin to mine and it maybe related to some change in the last update.

    Cheers Ray

    Tuesday, February 10, 2015 1:45 AM
  • User61518 posted

    Hi Ray,

    Thanks for posting. Glad it's not just me, and I hope one of the Xamarin team members get's back to us soon. Good luck with your issue.


    Tuesday, February 10, 2015 1:56 AM
  • User31231 posted


    I've moved this post to the Xamarin.Forms forum which is the better place for it.

    Also, could you please file a bug report with Bugzilla this is the best way to get it tracked and repaired by the Xamarin.Forms team.



    Tuesday, February 10, 2015 2:50 PM
  • User61518 posted

    Thanks Kevin. Filed a bug report yesterday; https://bugzilla.xamarin.com/show_bug.cgi?id=26890

    Tuesday, February 10, 2015 7:49 PM
  • User61518 posted

    Raymond, do you have 'generic value type sharing' enabled in your build properties? If not, are you able to turn it on and does it solve the problem? In a test project this seems to solve my current issue, but the checkbox is disabled in my real app's properties and I don't know why.

    Tuesday, February 10, 2015 8:17 PM
  • User5295 posted

    Hi Troy Ticking the Enable generic value type sharing under Project Properties->iOS Build->Advanced has allowed my application to run. Thank you for the heads up. I will add a comment to your bug report.

    Tuesday, February 10, 2015 10:12 PM