Forum Xamarin.Forms


The Xamarin Forums have officially moved to the new Microsoft Q&A experience. Microsoft Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

To create new threads and ask questions head over to Microsoft Q&A for .NET and get involved today.

Null reference exception in production at Xamarin.Forms.NavigationPage.GetHasBackButton

BinayBinay USMember

I am facing null reference exception in production at but not able to reproduce in dev. I am not getting any idea where is this coming from. Have anybody faced this?

The whole stack trace is below:

[Message:Value cannot be null.
Parameter name: page]==[StackTrace: at Xamarin.Forms.NavigationPage.GetHasBackButton (Xamarin.Forms.Page page) <0xa9c554 + 0x000a0> in :0
at Xamarin.Forms.Platform.iOS.NavigationRenderer.UpdateLeftBarButtonItem (Xamarin.Forms.Platform.iOS.ParentingViewController containerController) <0xbef714 + 0x0009f> in :0
at Xamarin.Forms.Platform.iOS.NavigationRenderer.<.ctor>b__9_0 (IVisualElementRenderer sender) <0xbf0184 + 0x000af> in :0
at Xamarin.Forms.MessagingCenter+<>c__DisplayClass4_0`1[TSender].b__0 (System.Object sender, System.Object args) <0xab1734 + 0x0009f> in :0
at Xamarin.Forms.MessagingCenter.InnerSend (System.String message, System.Type senderType, System.Type argType, System.Object sender, System.Object args) <0xab0f44 + 0x001b7> in :0
at Xamarin.Forms.MessagingCenter.Send[TSender] (Xamarin.Forms.TSender sender, System.String message) <0xab0a60 + 0x0004f> in :0
at Xamarin.Forms.Platform.iOS.TabletMasterDetailRenderer.HandlePropertyChanged (System.Object sender, System.ComponentModel.PropertyChangedEventArgs e) <0xc00b30 + 0x0016f> in :0
at (wrapper delegate-invoke) :invoke_void_object_PropertyChangedEventArgs (object,System.ComponentModel.PropertyChangedEventArgs)
at Xamarin.Forms.BindableObject.OnPropertyChanged (System.String propertyName) <0xa73c50 + 0x0006b> in :0
at Xamarin.Forms.Element.OnPropertyChanged (System.String propertyName) <0xafaf04 + 0x0002f> in :0
at Xamarin.Forms.BindableObject.SetValueActual (Xamarin.Forms.BindableProperty property, Xamarin.Forms.BindablePropertyContext context, System.Object value, Boolean currentlyApplying, SetValueFlags attributes, Boolean silent) <0xa754e8 + 0x00273> in :0
at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, SetValueFlags attributes, SetValuePrivateFlags privateAttributes) <0xa74818 + 0x00357> in :0
at Xamarin.Forms.BindableObject.SetValue (Xamarin.Forms.BindableProperty property, System.Object value, Boolean fromStyle, Boolean checkAccess) <0xa7531c + 0x0011b> in :0
at Xamarin.Forms.BindableObject.SetValue (Xamarin.Forms.BindableProperty property, System.Object value) <0xa73a1c + 0x0003b> in :0
at Xamarin.Forms.MasterDetailPage.set_IsPresented (Boolean value) <0xad4bcc + 0x0005b> in :0
at Xamarin.Forms.Platform.iOS.NavigationRenderer.b__58_0 (System.Object o, System.EventArgs e) <0xbf0460 + 0x00057> in :0
at UIKit.UIBarButtonItem+Callback.Call (Foundation.NSObject sender) <0x1b4c54 + 0x0005f> in :0
at (wrapper managed-to-native) UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
at UIKit.UIApplication.Main (System.String[] args, IntPtr principal, IntPtr delegate) <0x1b2108 + 0x00033> in :0
at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) <0x1b2030 + 0x000cb> in :0


  • ShaneHousteinShaneHoustein USMember ✭✭

    I'm experiencing the same issue. Did you find a solution?

  • benOnsidebenOnside Member

    Getting a similar error. The Xamarin part of the stack trace is as follows:

    NavigationPage.GetHasBackButton (Xamarin.Forms.Page page)
    NavigationRenderer+ParentingViewController.UpdateLeftBarButtonItem (Xamarin.Forms.Page pageBeingRemoved)
    NavigationRenderer.RemovePage (Xamarin.Forms.Page page)
    NavigationRenderer.OnRemovedPageRequested (System.Object sender, Xamarin.Forms.Internals.NavigationRequestedEventArgs e)
    NavigationPage.RemovePage (Xamarin.Forms.Page page)
    NavigationPage+NavigationImpl.OnRemovePage (Xamarin.Forms.Page page)
    NavigationProxy.RemovePage (Xamarin.Forms.Page page)
    NavigationProxy.OnRemovePage (Xamarin.Forms.Page page)
    NavigationProxy.RemovePage (Xamarin.Forms.Page page)
    NavigationService.TrimNavigationStack ()

    The thing both our errors have in common is that the child of a xamarin page is null, and this means it throws an exception when being deleted. My guess is that something else deletes the child first, so I'd like to introduce a lock around areas of our app that could interact with it. I'll let you know if I have any success

Sign In or Register to comment.