On Mar 24, 2012, at 8:32 AM, Paul Johnson wrote: >> Yes, logcat is available on both emulators and physical devices. > > Thanks for that. > > Logcat is showing something odd on the device which isn't showing on the > emulator...
The error: > I/MonoDroid( 618): UNHANDLED EXCEPTION: System.ArgumentOutOfRangeException: > Argument is out of range. > I/MonoDroid( 618): Parameter name: index > I/MonoDroid( 618): at > System.Collections.Generic.List`1<POHWS.webservice/UpcomingRaces>.get_Item > (int) <0x00064> > I/MonoDroid( 618): at oqhra_android.webservice_user.getUpcomingRacesCallBack > (string,System.Action`1<System.Collections.Generic.List`1<POHWS.webservice/UpcomingRaces>>) > <0x000ef> > I/MonoDroid( 618): at oqhra_android.oqhra_android.getUpcomingRaces > (Android.Widget.ListView,Android.Content.Context,string) <0x001b7> > I/MonoDroid( 618): at oqhra_android.oqhra_android.generateNewScreen (int) > <0x00443> > I/MonoDroid( 618): at oqhra_android.oqhra_android.listView_ItemClick > (object,Android.Widget.ItemEventArgs) <0x00067> > I/MonoDroid( 618): at Android.Widget.ItemClickImplementor.OnItemClick > (Android.Widget.AdapterView,Android.Views.View,int,long) <0x0008f> > I/MonoDroid( 618): at > Android.Widget.AdapterView/IOnItemClickListenerInvoker.n_OnItemClick_Landroid_widget_AdapterView_Landroid_view_View_IJ > (intptr,intptr,intptr,intptr,int,long) <0x000b3> > I/MonoDroid( 618): at (wrapper dynamic-method) > object.2dd985f4-fd58-4747-9c1d-7a5ba9100381 > (intptr,intptr,intptr,intptr,int,long) <0x0006b> The problem is an ArgumentOutOfRangeException from the List<T> indexer. Now we see the source code, looking for indexer usage: > public void getUpcomingRacesCallBack(string track, > Action<List<POHWS.webservice.UpcomingRaces>> callback) > { > var tableData = new List<POHWS.webservice.UpcomingRaces>(); > if (checkForNetwork(true) != true) > { > tableData[0].PostTime = "No network available"; And here we can see why we die. If checkForNetwork(true) returns false, we'll access tableData[0], which is an invalid index because we've never added anything to `tableData`. This should instead be: tableData.Add(new POHWS.webservice.UpcomingRaces { PostTime = "No network available" }); callback(tableData); That's not the only bad spot either: > if (tableData == null) > { > tableData[0].PostTime = "No Upcoming Races > Found within the next 7 days"; > callback(tableData); This is just begging for a NullReferenceException. Then there's the catch block, which could also trigger the ArgumentOutOfRangeException: > tableData[0].PostTime = oe.ToString(); > callback(tableData); I would suggest using tableData.Add() instead of tableData[0]. > That said System.Collections.Generic.List`1 looks dubious to be - why is > there a ` inserted? Because that's the name of the type. Disassemble mscorlib.dll and you'll see that the the name is System.Collections.Generic.List`1<T>. All CLS-conforming generic types have `N appended to the type name so that you can "overload" a generic type based on the number of type parameters, e.g. Action<T> is Action`1, Action<T1, T2> is Action`2, etc. - Jon _______________________________________________ Monodroid mailing list Monodroid@lists.ximian.com UNSUBSCRIBE INFORMATION: http://lists.ximian.com/mailman/listinfo/monodroid