2
votes

I am getting an index out of range exception when Popping a page from the navigation stack in my Xamarin Forms App on both iOS and Android.

I push the page onto the stack fine, then I can pop it the first time fine, then I push it on again fine but the second pop results in the exception.

Xamarin forms 3.0.0 iOS 11 Android 8.1.

Anyone experience this same issue?

As requested the stack when this occurs is NavigationPage -> ContentPage -> ContentPage -> TabPage -> ContentPage -> ContentPage.

The last content page is where the second call to PopAsync results in the exception.

1
could you post illustration with code please?Scarnet
I've described the stack in more detail, the only relevant code is Navigation.PushAsync(page); and Navigation.PopAsync();Rob Sanders
Before the second pop watch stack: var stack = Application.Current.MainPage.Navigation.NavigationStack;VahidShir
I would double check that you're pushing and popping from the same NavigationPageHichame Yessou
Thanks @hichame.yessou it turns out that was the case. It was to do with late deallocation of resources so that PopAsync was being called after the page had already been removed from the stack.Rob Sanders

1 Answers

1
votes

I would double check that you're pushing and popping from the same NavigationPage