I got an error while developing an app on ios using OrientationSensor.
System.ExecutionEngineException: Attempting to JIT compile method 'OrientationSensor.ReadingChanged
public partial class PanoramaPage : ContentPage
{
SphereApp sphereApp;
public PanoramaPage()
{
InitializeComponent();
/*Error: Attempting to JIT compile method: OrientationSensor.ReadingChanged*/
OrientationSensor.ReadingChanged += (sender, args) =>
{
System.Numerics.Quaternion q = args.Reading.Orientation;
// Convert to Urho Quaternion, and swap Y and Z values to
// convert from right-hand to left-hand coordinates.
sphereApp.Orientation = new Quaternion(q.X, q.Z, q.Y, q.W);
};
}
protected override async void OnAppearing()
{
base.OnAppearing();
// INITIALIZATION
sphereApp = await UrhoSurface.Show<SphereApp>(new Urho.ApplicationOptions(assetsFolder: "Data"));
try
{
OrientationSensor.Start(SensorSpeed.Default);
}
catch (Exception ex)
{
Content = new Label
{
//Text = "Sorry, the OrientationSensor is not supported on this device.",
Text = ex.ToString(),
VerticalOptions = LayoutOptions.Center,
HorizontalTextAlignment = TextAlignment.Center,
Margin = new Thickness(50)
};
}
}
protected override void OnDisappearing()
{
base.OnDisappearing();
OrientationSensor.Stop();
UrhoSurface.OnDestroy();
}
}


This is the project sample.
OrientationSensorTest.zip
Can you go into your iOS Build settings and check if you have this setting turned on:

sorry. I can't find the option: "Enable generic value type sharing" in visual studio for mac 2019. Can you show me the above option where?

@jamesmontemagno Rolf says this is a bug in the AOT compiler and should be moved to mono/mono.
I will have to find a workaround in the meantime. Will update as soon as I have anything.
Lovely thanks @mattleibow
Moving the issue to mono/mono: https://github.com/mono/mono/issues/20272
I discovered the cause of the error. My project was originally built using visual studio 2015, then I used visual studio 2019 to continue developing and got this error. I rebuilt the project using visual 2019 and it no longer has this error.
Thanks for the update! Closing now. Let us know if this happens again.
Most helpful comment
Moving the issue to mono/mono: https://github.com/mono/mono/issues/20272