BinarySerializer: Problem with deserialization on iOS

Attempting to deserialize the following object using Xamarin.iOS results in an error :

`public class PositionUpdatePackage { ///

/// Device serial number /// [FieldOrder(0)] public uint DeviceUniqueIdentifier { get; set; }

	/// <summary>
	/// Device latitude
	/// </summary>
	[FieldOrder(1)]
	public double Latitude { get; set; }

	/// <summary>
	/// Device longitude
	/// </summary>
	[FieldOrder(2)]
	public double Longitude { get; set; }

	/// <summary>
	/// Device speed in meters per seconds
	/// </summary>
	[FieldOrder(3)]
	public short SpeedInMetersPerSecond { get; set; }

	/// <summary>
	/// Device heading in degrees (true)
	/// </summary>
	[FieldOrder(4)]
	public short Heading { get; set; }

	/// <summary>
	/// Device altitude in meters
	/// </summary>
	[FieldOrder(5)]
	public short AltitudeInMeter { get; set; }

	/// <summary>
	/// Device GNSS receiver horizontal precision in meters
	/// </summary>
	[FieldOrder(6)]
	public byte HorizontalAccuracyInMeters { get; set; }

	/// <summary>
	/// Device GNSS receiver vertical precision in meters
	/// </summary>
	[FieldOrder(7)]
	public byte VerticalAccuracyInMeters { get; set; }

	/// <summary>
	/// integer expression of device DeviceTypes value
	/// </summary>
	[FieldOrder(8)]
	public short DeviceType { get; set; }

	/// <summary>
	/// Presure in hPa has measured by device
	/// </summary>
	[FieldOrder(9)]
	public short Pressure { get; set; }

	/// <summary>
	/// Pressure altitude calculated by device
	/// </summary>
	[FieldOrder(10)]
	public short PressureAltitude { get; set; }

	/// <summary>
	/// Variometer provided by GPS device
	/// </summary>
	[FieldOrder(11)]
	public short Variometer { get; set; }

	/// <summary>
	/// Latitude and Longitude convertited to Position object
	/// </summary>
	[Ignore]
	public Position Position
	{
		get {
			return new Position(Latitude, Longitude, SpeedInMetersPerSecond, Heading, AltitudeInMeter, HorizontalAccuracyInMeters, VerticalAccuracyInMeters);
		}
	}
}`

The error message is : System.ExecutionEngineException: Attempting to JIT compile method ‘(wrapper delegate-invoke) <Module>:invoke_callvirt_void_PositionUpdatePackage_double (aero.airprox.global.net.Messaging.FromMessagingPackages.PositionUpdatePackage,double)’ while running in aot-only mode. See https://developer.xamarin.com/guides/ios/advanced_topics/limitations/ for more information.

EDIT It works when the following class is deserialized: `public class AutonomousRegistrationReturnPackage { ///

/// Device Unique IDentifier attributed upon registration to be used for all further messages /// [FieldOrder(0)] public UInt32 DeviceUniqueIdentifier { get; set; }

	/// <summary>
	/// Device type expressed as int (cannot be null or equal to 0)
	/// </summary>
	[FieldOrder(1)]
	public Int16 DeviceType { get; set; }

	/// <summary>
	/// Minimum distance to send position changed message to cloud
	/// </summary>
	[FieldOrder(2)]
	public int MinimumDistanceInMeters { get; set; }

	/// <summary>
	/// Minimum timespan between position updates are sent to server
	/// </summary>
	[FieldOrder(3)]
	public int MinimumTimeInMilliseconds { get; set; }

	/// <summary>
	/// Dead man signal interval
	/// </summary>
	[FieldOrder(4)]
	public int DeadManSignalIntervalInMilliseconds { get; set; }

	/// <summary>
	/// Descirption (Friendly name, usually registration number) of device
	/// </summary>
	[FieldOrder(5)]
	public string Description { get; set; }

	/// <summary>
	/// Parameterless constructor used for serialization
	/// DO NOT USE
	/// </summary>
	public AutonomousRegistrationReturnPackage() { }

	/// <summary>
	/// Constructor for autonomous registration response message package
	/// </summary>
	/// <param name="fetchedIdentifier"></param>
	/// <param name="deviceType"></param>
	/// <param name="minimumDistance"></param>
	/// <param name="minimumTime"></param>
	/// <param name="deadMan"></param>
	/// <param name="desc"></param>
	public AutonomousRegistrationReturnPackage(UInt32 fetchedIdentifier, Int16 deviceType, int minimumDistance, int minimumTime, int deadMan, string desc)
	{
		DeviceUniqueIdentifier = fetchedIdentifier;
		DeviceType = deviceType;
		MinimumDistanceInMeters = minimumDistance;
		MinimumTimeInMilliseconds = minimumTime;
		DeadManSignalIntervalInMilliseconds = deadMan;
		Description = desc;
	}
}`

I must admit that I’m a bit confused, both by the error message ans the expalnation given on the link. Please note that the above code works perfectly on .NET framework (runs on azure worker role), UWP and Xamarin.Android.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 16 (11 by maintainers)

Commits related to this issue

Most upvoted comments

I have some theories. I just don’t have a Mac to test them. Still working on it though…


From: maddentist notifications@github.com Sent: Wednesday, April 18, 2018 8:34:27 AM To: jefffhaynes/BinarySerializer Cc: Jeff Haynes; Comment Subject: Re: [jefffhaynes/BinarySerializer] Problem with deserialization on iOS (#105)

Out of curiosity, what makes you think it has something to do with generic type support versus the other limitations listed in the link?

I’m not really certain 😃

Anyway, to add up to the mistery, it seems that the problem happens when the class the byte array is to be serialized into contains a double (or Double). I’ve tried with different classes that my project uses and lots of them are serialized/deserialized without a hiccup. I’ll explore this further if this is of any help.

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/jefffhaynes/BinarySerializer/issues/105#issuecomment-382370722, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AJSKR3H1zak6Yze9wl1qLTGv0K6uwLvtks5tpzLTgaJpZM4TQAkR.