[英]System.InvalidOperationException: 'No 'id' member found on type
I'm getting this error only on release build of xamarin forms IOS.我仅在 xamarin forms IOS 的发布版本中收到此错误。
App.xaml.cs 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.无论首先调用什么视图模型(调用 azure 移动服务) - 都会导致错误。
ShapesViewModel.cs 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).调用 GetSyncTable(Tablename) 时发生错误。
Shapes.cs形状.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).线程 0x6 以代码 0 (0x0) 退出。 2020-06-18 22:44:36.650 RangeFinder.iOS[571:98215] System.TypeInitializationException: The type initializer for 'RangeFinder.App' threw an exception.
2020-06-18 22:44:36.650 RangeFinder.iOS[571:98215] System.TypeInitializationException:“RangeFinder.App”的类型初始化程序引发了异常。 ---> System.InvalidOperationException: No 'id' member found on type 'RangeFinder.Models.ShapeTypes'.
---> System.InvalidOperationException:在类型“RangeFinder.Models.ShapeTypes”上找不到“id”成员。 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.Serializa
在 Microsoft.WindowsAzure.MobileServices.MobileServiceContractResolver.DetermineIdProperty(System.Type 类型,System.Collections.Generic.IEnumerable`1[T] 属性)[0x00070] in:0 在 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.Serializa tion.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) Z9CFED124ECBE655AF2
tion.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 在 RangeFinder.App..cctor () [0x00027] in C:\Users\Karl\Source\Repos\RangeFinder\RangeFinder.standard\Views\App.xaml.cs:36 --- 内部异常堆栈跟踪结束--- 在 RangeFinder.iOS.AppDelegate.FinishedLaunching(UIKit.UIApplication 应用程序,Foundation.NSDictionary 选项)[0x00093] 在 <92430b17376a435287b491877f96ca89>:0 在(包装器托管到本地)Z9CFED124 584273379C6AF4Z.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...'
584273379C6AF4Z.UIApplication.UIApplicationMain(int,string[],intptr,intptr) 在 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 在 UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) ] 在 /Library/Frameworks/Xamarin.iOS.framework/Versions/13.18.2.1/src/Xamarin.iOS/UIKit/UIApplication.cs:65 在 RangeFinder.iOS.Application.Main (System.String[] args) ] 在 <92430b17376a435287b491877f96ca89>:0 System.TypeInitializationException: '正在加载...'
Any help would be appreciated - as this is the last step before getting app published on IOS AppStore任何帮助将不胜感激 - 因为这是在 IOS AppStore 上发布应用程序之前的最后一步
You have not given is all the types involved.您没有给出涉及的所有类型。 See:
看:
No 'id' member found on type 'RangeFinder.Models.ShapeTypes'.
You explicitly want to look at RangeFinder.Models.ShapeTypes
type.您明确希望查看
RangeFinder.Models.ShapeTypes
类型。 There is no id field on that type.该类型没有 id 字段。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.