I'm getting this error only on release build of xamarin forms IOS.
App.xaml.cs
public partial class App : Application
{
public static MobileServiceClient MobileService = new MobileServiceClient(B2CConstants.ApplicationURL, new HttpClientHandler());
public static BaseViewModel BaseViewModel = new BaseViewModel();
public static ShapeTypeViewModel ShapeTypeViewModel = new ShapeTypeViewModel();
public static HoleDataViewModel HoleMapViewModel = new HoleDataViewModel();
public static PlayersViewModel PlayersViewModel = new PlayersViewModel();
public static RoundsViewModel RoundsViewModel = new RoundsViewModel();
public static ScoresViewModel ScoresViewModel = new ScoresViewModel();
public static TeeTimesViewModel TeeTimesViewModel = new TeeTimesViewModel();
public static TournamentViewModel TournamentSamplesViewModel = new TournamentViewModel();
public static ShapesViewModel ShapeViewModel = new ShapesViewModel();
public static MyTournamentsViewModel MyTournamentsViewModel = new MyTournamentsViewModel();
public static MyTournamentCoursesViewModel MyTournamentCoursesViewModel = new MyTournamentCoursesViewModel();
public static MyTournamentPlayersViewModel MyTournamentPlayersViewModel = new MyTournamentPlayersViewModel();
public static MyTournamentLeaderboardViewModel MyTournamentLeaderboardViewModel = new MyTournamentLeaderboardViewModel();
public static MyTournamentRoundsViewModel MyTournamentRoundsViewModel = new MyTournamentRoundsViewModel();
public static MyTournamentScoresViewModel MyTournamentScoresViewModel = new MyTournamentScoresViewModel();
public static MyTournamentYardagesViewModel MyTournamentYardagesViewModel = new MyTournamentYardagesViewModel();
Whatever viewmodel is called first (that calls azure mobile services)- causes the error.
ShapesViewModel.cs
public class ShapesViewModel : BaseViewModel
{
public MobileServiceCollection<GeoPosShapes, GeoPosShapes> shapeItems;
public IMobileServiceSyncTable<AzureShapes> ShapesTable = App.MobileService.GetSyncTable<AzureShapes>(); // offline sync
The error occurs on calling GetSyncTable(Tablename).
Shapes.cs
namespace RangeFinder.Models
{
public class AzureShapes
{
public string id { get; set; }
public int shapetypeid { get; set; }
public string courseid { get; set; }
[JsonProperty(PropertyName = "wkt")]
public string WKT { get; set; }
[JsonProperty(PropertyName = "hole")]
public int Hole { get; set; }
}
public class GeoPosShapes
{
public string id { get; set; }
public int shapetypeid { get; set; }
public string courseid { get; set; }
[JsonProperty(PropertyName = "hole")]
public int Hole { get; set; }
public List<Position> PolyGeoPos { get; set; }
//public MapElement mapElement { get; set; }
}
}
The error message is:
The thread 0x6 has exited with code 0 (0x0). 2020-06-18 22:44:36.650 RangeFinder.iOS[571:98215] System.TypeInitializationException: The type initializer for 'RangeFinder.App' threw an exception. ---> System.InvalidOperationException: No 'id' member found on type 'RangeFinder.Models.ShapeTypes'. at Microsoft.WindowsAzure.MobileServices.MobileServiceContractResolver.DetermineIdProperty (System.Type type, System.Collections.Generic.IEnumerable`1[T] properties) [0x00070] in :0 at Microsoft.WindowsAzure.MobileServices.MobileServiceContractResolver.CreatePropertiesInner (System.Type type, Newtonsoft.Json.MemberSerialization memberSerialization) [0x00075] in :0 at Microsoft.WindowsAzure.MobileServices.MobileServiceContractResolver.CreateProperties (System.Type type, Newtonsoft.Json.MemberSerialization memberSerialization) [0x0004f] in :0 at Newtonsoft.Json.Serialization.DefaultContractResolver.CreateObjectContract (System.Type objectType) [0x0003a] in <2073514815234917a5e8f91b0b239405>:0 at Microsoft.WindowsAzure.MobileServices.MobileServiceContractResolver.CreateObjectContract (System.Type objectType) [0x00000] in :0 at Newtonsoft.Json.Serialization.DefaultContractResolver.CreateContract (System.Type objectType) [0x0010f] in <2073514815234917a5e8f91b0b239405>:0 at Microsoft.WindowsAzure.MobileServices.MobileServiceContractResolver.ResolveTableName (System.Type type) [0x000ea] in :0 at Microsoft.WindowsAzure.MobileServices.MobileServiceClient.GetSyncTable[T] () [0x0000b] in :0 at RangeFinder.ViewModels.ShapeTypeViewModel..ctor () [0x00000] in C:\Users\Karl\Source\Repos\RangeFinder\RangeFinder.standard\ViewModels\ShapeTypeViewModel.cs:13 at RangeFinder.App..cctor () [0x00027] in C:\Users\Karl\Source\Repos\RangeFinder\RangeFinder.standard\Views\App.xaml.cs:36 --- End of inner exception stack trace --- at RangeFinder.iOS.AppDelegate .FinishedLaunching (UIKit.UIApplication app, Foundation.NSDictionary options) [0x00093] in <92430b17376a435287b491877f96ca89>:0 at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr) at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.18.2.1/src/Xamarin.iOS/UIKit/UIApplication.cs:86 at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0000e] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.18.2.1/src/Xamarin.iOS/UIKit/UIApplication.cs:65 at RangeFinder.iOS.Application.Main (System.String[] args) [0x00000] in <92430b17376a435287b491877f96ca89>:0 System.TypeInitializationException: 'Loading...'
Any help would be appreciated - as this is the last step before getting app published on IOS AppStore