ShellLoginSample
ShellLoginSample copied to clipboard
Logout null reference exception
Hi, I'm trying to implement a log out functionality with the following code:
private async void LogoutButton_Clicked(object sender, EventArgs e)
{
await Xamarin.Essentials.SecureStorage.SetAsync("isLogged", "0");
Application.Current.MainPage = new LoginPage();
await Shell.Current.GoToAsync("//login");
}
But I keep getting "Object reference not set to an instance of an object."
Stacktrace only shows: at Project1.Mobile.Shared.Views.ProfilePage.LogoutButton_Clicked (System.Object sender, System.EventArgs e) [0x00093] in F:\Development\Project1\Project1\Project1.Mobile.Shared\Views\ProfilePage.xaml.cs:20 at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.<ThrowAsync>b__7_0 (System.Object state) [0x00000] in /Users/builder/jenkins/workspace/archive-mono/2019-10/android/release/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/AsyncMethodBuilder.cs:1021 at Android.App.SyncContext+<>c__DisplayClass2_0.<Post>b__0 () [0x00000] in <4ccdb3137d974856b786e1aeebbfbab6>:0 at Java.Lang.Thread+RunnableImplementor.Run () [0x00008] in <4ccdb3137d974856b786e1aeebbfbab6>:0 at Java.Lang.IRunnableInvoker.n_Run (System.IntPtr jnienv, System.IntPtr native__this) [0x00009] in <4ccdb3137d974856b786e1aeebbfbab6>:0 at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.52(intptr,intptr)
The Logout button is in ProfilePage that's part of the AppShell.
Any ideas what could it be?