Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 58056

How to resolve the NavigationProxy.set_inner() exception?

$
0
0

In my implementation, I'm using a MasterDetailPage, but when I'm instantiating this page, I get this error:

" at Xamarin.Forms.NavigationProxy.set_Inner (INavigation value) [0x00000] in :0 \n at Xamarin.Forms.VisualElement.OnParentSet () [0x00000] in :0 \n at Xamarin.Forms.Page.OnParentSet () [0x00000] in :0 \n at Xamarin.Forms.Element.set_Parent (Xamarin.Forms.Element value) [0x00000] in :0 \n at Xamarin.Forms.Element.OnChildAdded (Xamarin.Forms.Element child) [0x00000] in :0 \n at Xamarin.Forms.Page.OnInternalAdded (Xamarin.Forms.VisualElement view) [0x00000] in :0 \n at Xamarin.Forms.Page.InternalChildrenOnCollectionChanged (System.Object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x00000] in :0 \n at System.Collections.ObjectModel.ObservableCollection1[Xamarin.Forms.Element].OnCollectionChanged (System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x00000] in <filename unknown>:0 \n at System.Collections.ObjectModel.ObservableCollection1[Xamarin.Forms.Element].InsertItem (Int32 index, Xamarin.Forms.Element item) [0x00000] in :0 \n at System.Collections.ObjectModel.Collection`1[Xamarin.Forms.Element].Add (Xamarin.Forms.Element item) [0x00000] in :0 \n at Xamarin.Forms.NavigationPage.PushPage (Xamarin.Forms.Page page) [0x00000] in :0 \n at Xamarin.Forms.NavigationPage..ctor (Xamarin.Forms.Page root) [0x00000] in :0 \n at Pages.MasterPage.SetupDetailView () [0x0001e] in c:\Users\JackS\Documents\Visual Studio 2013\Projects\\Pages\MasterPage.cs:80 "

I will try to describe my problem. If the user isn't logged in to my application, he needs to log in. If there are already credentials saved, the user goes right o the application. If the user isn't authenticated, the following code gets triggered:

public class BaseView : ContentPage
{

    protected override void OnAppearing()
    {

        if ( ! App.Instance.IsAuthenticated)
        {
            Navigation.PushModalAsync(new LoginPage());
        }

        base.OnAppearing();

    } 
}

All my pages are child classes of this class. So when my App has an indication that the user isn't logged in anymore, it needs to show the LoginPage.

When an user logs in, this Action goes off:

public Action SuccessfulLoginAction
    {
        get
        {
    return new Action(() => {
                Navigation.PopModalAsync();
        MasterPage.Instance.Init();
    });
        }
    }

The MasterPage Init() method, looks like the following:

    public void Init() {

        SetupMasterView ();

             if(App.Instance.IsAuthenticated) {
                    SetupDetailView ();
                    return;

            }

                Detail = new ContentPage();

    }

Now the SetupDetailView method is were it goes wrong after a certain scenario.

    private void SetupDetailView() {

        try
        {

            NavigationPage homeNav;

            _homeView = GetPage(menuView.PageSelection) as HomeView;

         // This is the line were the NullReference is thrown.
            homeNav = new NavigationPage(_homeView);

            Detail = homeNav;

            Pages.Add(MenuType.Home, homeNav);

            menuView.PageSelectionChanged = PageSelectionChanged;

        }
        catch (Exception exception)
        {
            throw exception;
        }


    }

I only get the NullReference on Android and I only get the NullReference in the following situation:

  • When the user isn't logged in and the login succeeded. The Modal is Popped and the Exception is thrown. Apparantly because there is nothing left on the stack?

Is there a workaround?


Viewing all articles
Browse latest Browse all 58056

Trending Articles