Forum Xamarin.iOS

Announcement:

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.

Sometimes System.ArgumentOutOfRangeException ListView (iOS) (EDITED)

kenneth.leekenneth.lee USMember ✭✭✭
edited November 2017 in Xamarin.iOS

tl;dr important bits are after edit...

Hi everyone,

Recently I got a user which experienced a crash using my app. I tried to replicate what the user did but it didn't do the same thing on my device, so i thought to look into the crash logs which i got from the users device.

I can see that an EXC_CRASH is what caused it which would probably mean an uncaught exception by my code. But looking at the stacktrace of the thread which it crashed on i can't really tell what actually caused the uncaught exception. I having a real hard time trying to understand the crash log and am not sure what else to do then just staring at the logs which almost look like gibberish to me.

I'm not sure if i'm looking at the wrong logs or I just don't understand what the logs are telling me.
Please any help would be greatly appreciated.

EDIT:
New light is shed on the issue
I was able to replicate the issue now on my device and get exactly the same issue.
It seems to say System.ArgumentOutOfRangeException when i attach a debugger to it. The problem is that it only does it if i don't put breakpoints and let the code run normally. If i do step through the code step by step slowly enough it doesn't throw this exception.

I have an ObservableCollection linked to a list view and this is populated on the page's OnAppearing in an async task. It seems the listview is bugging out when i do so however im unsure if this is intended (meaning i have implemented this wrongly) or not (which case the ListView is meant to be able to do this).

Someone please advice...

Answers

  • kenneth.leekenneth.lee USMember ✭✭✭
      at System.ThrowHelper.ThrowArgumentOutOfRangeException (System.ExceptionArgument argument, System.ExceptionResource resource) [0x00018] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.3.0.47/src/mono/mcs/class/referencesource/mscorlib/system/throwhelper.cs:93 
      at System.ThrowHelper.ThrowArgumentOutOfRangeException () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.3.0.47/src/mono/mcs/class/referencesource/mscorlib/system/throwhelper.cs:56 
      at System.Collections.Generic.List`1[T].get_Item (System.Int32 index) [0x00009] in <136edfc8e644410eb152bce382121c61>:0 
      at Cadenza.Collections.OrderedDictionary`2[TKey,TValue].get_Item (System.Int32 index) [0x00000] in <0f1ce60dbc6b4e24af01294c7acf41c6>:0 
      at Xamarin.Forms.TemplatedItemsList`2[TView,TItem].GetGroup (System.Int32 index) [0x0000a] in <0f1ce60dbc6b4e24af01294c7acf41c6>:0 
      at Xamarin.Forms.TemplatedItemsList`2[TView,TItem].System.Collections.IList.get_Item (System.Int32 index) [0x00008] in <0f1ce60dbc6b4e24af01294c7acf41c6>:0 
      at Xamarin.Forms.Platform.iOS.ListViewRenderer+ListViewDataSource.RowsInSection (UIKit.UITableView tableview, System.nint section) [0x00047] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.iOS\Renderers\ListViewRenderer.cs:894 
      at (wrapper managed-to-native) ObjCRuntime.Messaging:void_objc_msgSend (intptr,intptr)
      at UIKit.UITableView.ReloadData () [0x00010] in /Users/builder/data/lanes/5520/51128b8c/source/xamarin-macios/src/build/ios/native/UIKit/UITableView.g.cs:792 
      at Xamarin.Forms.Platform.iOS.ListViewRenderer.UpdateItems (System.Collections.Specialized.NotifyCollectionChangedEventArgs e, System.Int32 section, System.Boolean resetWhenGrouped) [0x00240] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.iOS\Renderers\ListViewRenderer.cs:549 
      at Xamarin.Forms.Platform.iOS.ListViewRenderer.OnCollectionChanged (System.Object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x00000] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.iOS\Renderers\ListViewRenderer.cs:283 
      at Xamarin.Forms.TemplatedItemsList`2[TView,TItem].OnCollectionChanged (System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x0000a] in <0f1ce60dbc6b4e24af01294c7acf41c6>:0 
      at Xamarin.Forms.TemplatedItemsList`2[TView,TItem].OnCollectionChangedGrouped (System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x000e3] in <0f1ce60dbc6b4e24af01294c7acf41c6>:0 
      at Xamarin.Forms.TemplatedItemsList`2[TView,TItem].OnProxyCollectionChanged (System.Object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e, System.Boolean fixWindows) [0x00008] in <0f1ce60dbc6b4e24af01294c7acf41c6>:0 
      at Xamarin.Forms.TemplatedItemsList`2[TView,TItem].OnProxyCollectionChanged (System.Object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x00000] in <0f1ce60dbc6b4e24af01294c7acf41c6>:0 
      at Xamarin.Forms.ListProxy.OnCollectionChanged (System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x0000a] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\ListProxy.cs:230 
      at Xamarin.Forms.ListProxy+<>c__DisplayClass32_0.<OnCollectionChanged>b__0 () [0x00018] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\ListProxy.cs:203 
      at Foundation.NSAsyncActionDispatcher.Apply () [0x00000] in /Users/builder/data/lanes/5520/51128b8c/source/xamarin-macios/src/Foundation/NSAction.cs:163 
      at (wrapper managed-to-native) UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
      at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Users/builder/data/lanes/5520/51128b8c/source/xamarin-macios/src/UIKit/UIApplication.cs:79 
      at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00038] in /Users/builder/data/lanes/5520/51128b8c/source/xamarin-macios/src/UIKit/UIApplication.cs:63 
      at MobileApp.iOS.Application.Main (System.String[] args) [0x00001] in /Users/-dev1/Projects/-mobile-app-2/iOS/Main.cs:18 
    
  • SteveShaw.5557SteveShaw.5557 USMember ✭✭✭

    For anyone searching the title of this thread:

    Make sure you are on the UI thread when changing a bound property. I got an exception similar to this, but I discovered the code was running on a background thread. I suspect the UI was trying to draw a cell that referred to data that was no longer in the collection.

Sign In or Register to comment.