ArgumentOutOfRangeException after calling Navigation.PopAsync

Palo_spPalo_sp Member ✭✭
edited July 26 in Xamarin.Forms

Hi guys..

I have a problem after I update Xamarin.Forms. This code was working with version 3.2.0.871581, but after updating to 3.3.0.912540 or newer I get this weird problem calling:

while (Navigation.NavigationStack.Count > 1)
{
    //await Navigation.PopToRootAsync(animated);
    await Navigation.PopAsync(animated);
}

When I first start application everything works fine.. I can jump between pages with this code. But when I close app and start it again. I am getting ArgumentOutOfRangeException after this code is run. Even when NavigationStack.Count is 2. When I try PopToRootAsync (commented in code sample) its the same result. This only happens on Android.. with iOS same code is OK.

Here is call stack:

  {System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
  at System.Collections.Generic.List`1[T].get_Item (System.Int32 index) [0x00009] in <3a61d48d66dd458fa0b64990b6c8f8cc>:0 
  at Xamarin.Forms.Platform.Android.AppCompat.NavigationPageRenderer.GetFragment (Xamarin.Forms.Page page, System.Boolean removed, System.Boolean popToRoot) [0x00003] in D:\a\1\s\Xamarin.Forms.Platform.Android\AppCompat\NavigationPageRenderer.cs:884 
  at Xamarin.Forms.Platform.Android.AppCompat.NavigationPageRenderer.SwitchContentAsync (Xamarin.Forms.Page page, System.Boolean animated, System.Boolean removed, System.Boolean popToRoot) [0x0001a] in D:\a\1\s\Xamarin.Forms.Platform.Android\AppCompat\NavigationPageRenderer.cs:787 
  at Xamarin.Forms.Platform.Android.AppCompat.NavigationPageRenderer.OnPopViewAsync (Xamarin.Forms.Page page, System.Boolean animated) [0x00017] in D:\a\1\s\Xamarin.Forms.Platform.Android\AppCompat\NavigationPageRenderer.cs:609 
  at Xamarin.Forms.Platform.Android.AppCompat.NavigationPageRenderer.PopViewAsync (Xamarin.Forms.Page page, System.Boolean animated) [0x00000] in D:\a\1\s\Xamarin.Forms.Platform.Android\AppCompat\NavigationPageRenderer.cs:156 
  at Xamarin.Forms.Platform.Android.AppCompat.NavigationPageRenderer.OnPopped (System.Object sender, Xamarin.Forms.Internals.NavigationRequestedEventArgs e) [0x00000] in D:\a\1\s\Xamarin.Forms.Platform.Android\AppCompat\NavigationPageRenderer.cs:590 
  at Xamarin.Forms.NavigationPage.Xamarin.Forms.INavigationPageController.RemoveAsyncInner (Xamarin.Forms.Page page, System.Boolean animated, System.Boolean fast) [0x0004c] in D:\a\1\s\Xamarin.Forms.Core\NavigationPage.cs:325 
  at Xamarin.Forms.NavigationPage.PopAsyncInner (System.Boolean animated, System.Boolean fast) [0x0004c] in D:\a\1\s\Xamarin.Forms.Core\NavigationPage.cs:308 
  at Xamarin.Forms.NavigationPage.PopAsync (System.Boolean animated) [0x00140] in D:\a\1\s\Xamarin.Forms.Core\NavigationPage.cs:190 
  at XTokenPortable.MyNavigationPage.GoToRoot (System.Boolean animated) [0x00115] in pathtoproject\Shared\MyNavigationPage.cs:112 }

Do you have any ideas what can be wrong?

Best Answer

Answers

Sign In or Register to comment.