Forum Xamarin.Forms

App.Current.MainPage - NullReferenceException

NeocomerNeocomer GBMember ✭✭

I keep getting this error when i try to set the main page of my app to other page.
this normally occurs on a login page after a user and signed in, but not when the app just starts up and i set the main page to the login page in then app.cs
sometimes the error occurs on the login then login - thought quite rarely
other times i have to login and logout and login 10+ times before it breaks.
Application.Current.MainPage = (new NavigationPage(new Pages.Sales.Sales()));
just wondering if anyone has come across this problem , and knows possible work around or just if someone knows the inner workings of xamarin to know
why this may be occurring.
This is my Stack-trace form the exception.
System.NullReferenceException: Object reference not set to an instance of an object.
at Xamarin.Forms.Platform.Android.AppCompat.Platform.SetPage (Xamarin.Forms.Page newRoot) [0x0003f] in C:\BuildAgent2\work\aad494dc9bc9783\Xamarin.Forms.Platform.Android\AppCompat\Platform.cs:226
at Xamarin.Forms.Platform.Android.FormsAppCompatActivity.InternalSetPage (Xamarin.Forms.Page page) [0x0001a] in C:\BuildAgent2\work\aad494dc9bc9783\Xamarin.Forms.Platform.Android\AppCompat\FormsAppCompatActivity.cs:355
at Xamarin.Forms.Platform.Android.FormsAppCompatActivity.AppOnPropertyChanged (System.Object sender, System.ComponentModel.PropertyChangedEventArgs args) [0x00012] in C:\BuildAgent2\work\aad494dc9bc9783\Xamarin.Forms.Platform.Android\AppCompat\FormsAppCompatActivity.cs:308
at Xamarin.Forms.BindableObject.OnPropertyChanged (System.String propertyName) [0x0000a] in C:\BuildAgent2\work\aad494dc9bc9783\Xamarin.Forms.Core\BindableObject.cs:137
at Xamarin.Forms.Element.OnPropertyChanged (System.String propertyName) [0x00000] in C:\BuildAgent2\work\aad494dc9bc9783\Xamarin.Forms.Core\Element.cs:369
at Xamarin.Forms.Application.set_MainPage (Xamarin.Forms.Page value) [0x0008b] in C:\BuildAgent2\work\aad494dc9bc9783\Xamarin.Forms.Core\Application.cs:88
at App.Pages.Access.Login+d__2.MoveNext () [0x001af] in C:\Projects\eSuite\eSuite.Apps\5001012\App\Pages\Access\Login.xaml.cs:51


  • MdNaushadMdNaushad INMember ✭✭✭

    Did you find solution for this?
    For me this was working fine all the while, and now suddenly out of nowhere I have started seeing this exception.

Sign In or Register to comment.