private const string LoggedUserKey = "loggeduser_key";
private static readonly User LoggedUserDefault = null; // I also tried new User();
public static User LoggedUser {
get { return AppSettings.GetValueOrDefault<User>(LoggedUserKey, LoggedUserDefault); }
set { AppSettings.AddOrUpdateValue<User>(LoggedUserKey, value); }
}
In the constructor of my MainPageViewModel, I have this:
if (Settings.LoggedUser != null) {
Debug.WriteLine("User is not null");
}
But I got this error:
System.NullReferenceException: Object reference not set to an instance of an object.
I have this model:
And the settings are:
In the constructor of my MainPageViewModel, I have this:
But I got this error: System.NullReferenceException: Object reference not set to an instance of an object.