Monday 15 September 2014

c# - System.Reflection.TargetOfInvocation exception when loading new List -


I have a MvxListView that is linked to a collection when I first navigate to ViewModel I do, I load the data from the server and set the list. The view load is very good.

I then set a OnScroll listener in ListView , so that I can load the next page when the user scrolls down the floor. I kick the command to get the following command using a command of "next page" result:

  this.ViewModel.ShowNextPageCommand.Execute (null);   

Command finally calls a method that uses some position in the modal, to get the next page, all this is working fine, but when I actually get the property For the update that is going to update that list view is bound, I get the following error -

  Reflection.TargetInvocationException: Exception is thrown by the goal of a greeting --- & gt; Android Use the. Android Rendime Exception: 'The Exception of the Type of Android Util Androidtime exposure 'was thrown. 06-21 14: 58: 27.969 e / Mono (28,485): Android.Runtime.JNIEnv.CallNonvirtualVoidMethod (IntPtr jobject, IntPtr jclass, IntPtr jmethod) [0x00023] in / users / builder / data / alleys / monodroid-lion-on BS1 / 0cc7ae3b / source / monodroid / src / mono.Android / src / runtime / JNIEnv.g.cs: 604 06-21 14: 58: 27.969 e / mono (28,485): on Android.Widget.BaseAdapter.NotifyDataSetChanged () [0x00053] /Users/builder/data/lanes/monodroid-lion-bs1/0cc7ae3b/source/monodroid/src/Mono.Android/platforms/android-14/src/generated/Android.Widget.BaseAdapter.cs9393   

The property looks like:

  Private Icicle & lt; Part & gt; Parts; Public icon & lt; Part & gt; Parts {Get Return Parts; } Set {this.parts = value; RaisePropertyChanged ((= = Parts); }}   

And the code that updates the property looks like this:

  Private Zero HandlePartResults (PartsResults result) {if (this.Results = = Void) {this. Result = results; this. Pars = results. P; } And this. result. Links Claire (); This.Results.Links.AddRange (results.Links); Parrot (result in different parts part) {this.Results.Parts.Add (part); } Mvx.Trace (MvxTraceLevel.Diagnostic, Results.Parts.Count.ToString ()); this. Part = results Run; } this is. Loading = false; }   

My layout looks like the following:

  & lt ;? Xml version = "1.0" encoding = "UTF-8"? & Gt; & Lt; FrameLayout xmlns: Android = "http://schemas.android.com/apk/res/android" xmlns: local = "http://schemas.android.com/apk/res/com.x3wire.mobile.android" Android : Layout_width = "fill_parent" android: layout_height = "fill_parent" & gt; & Lt; ProgressBar Android: layout_width = "100dp" Android: layout_height = "100dp" Android: layout_gravity = "center" local: MvxBind = "Visibility IsLoading, Converter = Visibility" /> & Lt; Mvx.MvxListView Android: Layout_width = "Fill_parent" Android: Layout_height = "Fill_parent" android: orientation = "vertical" android: id = "@ + id / PartResultsList" local: MvxItemTemplate = "@ layout / partslistitem" local: MvxBind = " ItemSource Parts; ItemClick Show Credit Commands "/ & gt; & Lt; / FrameLayout & gt;   

I have also tried to use an observation archive but I get the same exception. Is anything clear that I am doing wrong here?

I ran out of what was the problem (this was not an MVVMcross problem at all). Once I've fixed your debugger, it was clear some threading issues (and Onscroll audience that is getting fired more than needed it).

Long story short, make sure that more than one thread to make you do not need to modify a collection at the same time when it is bound to a scene and make sure you console.writes tax through trying to make do not try to debug such issues: D

No comments:

Post a Comment