所以我正在构建一个Xamarin Forms应用程序,并且我想知道如何找出造成此异常的原因:TargetParameterCountException: Number of parameters specified does not match the expected number
堆栈跟踪并不指向我们的任何代码(堆栈跟踪仅表示从UIApplication.Main
抛出异常)。
我只是不知道如何来追踪此异常的来源 - 如果我单步执行我的调试跟踪显示的代码是逐行运行的,那么代码工作正常。
此问题仅在安装后第一次使用该应用时遇到,这给了我一个线索,但我真的不知道在哪里进一步调查。
编辑:
根据要求,这里是堆栈跟踪:
System.Reflection.TargetParameterCountException: Number of parameters specified does not match the expected number.
at System.Reflection.MonoMethod.ConvertValues (System.Reflection.Binder binder, System.Object[] args, System.Reflection.ParameterInfo[] pinfo, System.Globalization.CultureInfo culture, System.Reflection.BindingFlags invokeAttr) [0x00008] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.0.0.0/src/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:327
at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00011] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.0.0.0/src/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:293
at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.0.0.0/src/mono/mcs/class/referencesource/mscorlib/system/reflection/methodbase.cs:229
at Xamarin.Forms.BindingExpression+BindingExpressionPart.TryGetValue (System.Object source, System.Object& value) [0x00043] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\BindingExpression.cs:562
at Xamarin.Forms.BindingExpression.ApplyCore (System.Object sourceObject, Xamarin.Forms.BindableObject target, Xamarin.Forms.BindableProperty property, System.Boolean fromTarget) [0x000d4] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\BindingExpression.cs:131
at Xamarin.Forms.BindingExpression.Apply (System.Object sourceObject, Xamarin.Forms.BindableObject target, Xamarin.Forms.BindableProperty property) [0x0006b] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\BindingExpression.cs:76
at Xamarin.Forms.Binding.Apply (System.Object newContext, Xamarin.Forms.BindableObject bindObj, Xamarin.Forms.BindableProperty targetProperty) [0x00042] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\Binding.cs:123
at Xamarin.Forms.BindableObject.ApplyBindings (System.Boolean skipBindingContext) [0x0003b] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\BindableObject.cs:417
at Xamarin.Forms.BindableObject.ApplyBindings () [0x00000] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\BindableObject.cs:124
at Xamarin.Forms.BindableObject.SetInheritedBindingContext (Xamarin.Forms.BindableObject bindable, System.Object value) [0x0005a] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\BindableObject.cs:118
at Xamarin.Forms.Element.SetChildInheritedBindingContext (Xamarin.Forms.Element child, System.Object context) [0x00000] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\Element.cs:483
at Xamarin.Forms.Element.OnBindingContextChanged () [0x00021] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\Element.cs:333
at Xamarin.Forms.View.OnBindingContextChanged () [0x00042] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\View.cs:99
at Xamarin.Forms.BindableObject.SetInheritedBindingContext (Xamarin.Forms.BindableObject bindable, System.Object value) [0x00060] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\BindableObject.cs:119
at Xamarin.Forms.Element.SetChildInheritedBindingContext (Xamarin.Forms.Element child, System.Object context) [0x00000] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\Element.cs:483
at Xamarin.Forms.Element.OnBindingContextChanged () [0x00021] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\Element.cs:333
at Xamarin.Forms.View.OnBindingContextChanged () [0x00042] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\View.cs:99
at Xamarin.Forms.Grid.OnBindingContextChanged () [0x00006] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\Grid.cs:139
at Xamarin.Forms.BindableObject.SetInheritedBindingContext (Xamarin.Forms.BindableObject bindable, System.Object value) [0x00060] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\BindableObject.cs:119
at Xamarin.Forms.Element.SetChildInheritedBindingContext (Xamarin.Forms.Element child, System.Object context) [0x00000] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\Element.cs:483
at Xamarin.Forms.Element.OnBindingContextChanged () [0x00021] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\Element.cs:333
at Xamarin.Forms.View.OnBindingContextChanged () [0x00042] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\View.cs:99
at Xamarin.Forms.Grid.OnBindingContextChanged () [0x00006] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\Grid.cs:139
at Xamarin.Forms.BindableObject.SetInheritedBindingContext (Xamarin.Forms.BindableObject bindable, System.Object value) [0x00060] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\BindableObject.cs:119
at Xamarin.Forms.Element.SetChildInheritedBindingContext (Xamarin.Forms.Element child, System.Object context) [0x00000] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\Element.cs:483
at Xamarin.Forms.TemplatedView.SetChildInheritedBindingContext (Xamarin.Forms.Element child, System.Object context) [0x00008] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\TemplatedView.cs:65
at Xamarin.Forms.Element.OnBindingContextChanged () [0x00021] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\Element.cs:333
at Xamarin.Forms.View.OnBindingContextChanged () [0x00042] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\View.cs:99
at Xamarin.Forms.ContentView.OnBindingContextChanged () [0x00000] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\ContentView.cs:16
at Xamarin.Forms.BindableObject.SetInheritedBindingContext (Xamarin.Forms.BindableObject bindable, System.Object value) [0x00060] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\BindableObject.cs:119
at Xamarin.Forms.Element.SetChildInheritedBindingContext (Xamarin.Forms.Element child, System.Object context) [0x00000] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\Element.cs:483
at Xamarin.Forms.Element.OnBindingContextChanged () [0x00021] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\Element.cs:333
at Xamarin.Forms.View.OnBindingContextChanged () [0x00042] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\View.cs:99
at Xamarin.Forms.BindableObject.SetInheritedBindingContext (Xamarin.Forms.BindableObject bindable, System.Object value) [0x00060] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\BindableObject.cs:119
at Xamarin.Forms.Element.SetChildInheritedBindingContext (Xamarin.Forms.Element child, System.Object context) [0x00000] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\Element.cs:483
at Xamarin.Forms.Element.OnBindingContextChanged () [0x00021] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\Element.cs:333
at Xamarin.Forms.Cell.OnBindingContextChanged () [0x00000] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\Cells\Cell.cs:118
at Xamarin.Forms.BindableObject.BindingContextPropertyChanged (Xamarin.Forms.BindableObject bindable, System.Object oldvalue, System.Object newvalue) [0x0000e] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\BindableObject.cs:437
at Xamarin.Forms.BindableObject.SetValueActual (Xamarin.Forms.BindableProperty property, Xamarin.Forms.BindableObject+BindablePropertyContext context, System.Object value, System.Boolean currentlyApplying, Xamarin.Forms.BindableObject+SetValueFlags attributes, System.Boolean silent) [0x00108] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\BindableObject.cs:592
at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, Xamarin.Forms.BindableObject+SetValueFlags attributes, Xamarin.Forms.BindableObject+SetValuePrivateFlags privateAttributes) [0x0015b] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\BindableObject.cs:386
at Xamarin.Forms.BindableObject.SetValue (Xamarin.Forms.BindableProperty property, System.Object value, System.Boolean fromStyle, System.Boolean checkAccess) [0x0005f] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\BindableObject.cs:539
at Xamarin.Forms.BindableObject.SetValue (Xamarin.Forms.BindableProperty property, System.Object value) [0x00000] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\BindableObject.cs:83
at Xamarin.Forms.BindableObject.set_BindingContext (System.Object value) [0x00000] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\BindableObject.cs:24
at Xamarin.Forms.TemplatedItemsList`2[TView,TItem].UpdateContent (TItem content, System.Int32 index, System.Object item) [0x00000] in <7fc7c54b5e2d419395df064dc5addbb6>:0
at Xamarin.Forms.TemplatedItemsList`2[TView,TItem].CreateContent (System.Int32 index, System.Object item, System.Boolean insert) [0x00038] in <7fc7c54b5e2d419395df064dc5addbb6>:0
at Xamarin.Forms.TemplatedItemsList`2[TView,TItem].GetOrCreateContent (System.Int32 index, System.Object item) [0x00023] in <7fc7c54b5e2d419395df064dc5addbb6>:0
at Xamarin.Forms.TemplatedItemsList`2[TView,TItem].get_Item (System.Int32 index) [0x0000e] in <7fc7c54b5e2d419395df064dc5addbb6>:0
at Xamarin.Forms.Platform.iOS.ListViewRenderer+ListViewDataSource.GetHeightForHeader (UIKit.UITableView tableView, System.nint section) [0x0000d] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.iOS\Renderers\ListViewRenderer.cs:782
at (wrapper managed-to-native) ObjCRuntime.Messaging:void_objc_msgSend (intptr,intptr)
at UIKit.UITableView.ReloadData () [0x00010] in /Users/builder/data/lanes/5024/152b654a/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 <7fc7c54b5e2d419395df064dc5addbb6>:0
at Xamarin.Forms.TemplatedItemsList`2[TView,TItem].OnCollectionChangedGrouped (System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x000e3] in <7fc7c54b5e2d419395df064dc5addbb6>:0
at Xamarin.Forms.TemplatedItemsList`2[TView,TItem].OnProxyCollectionChanged (System.Object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e, System.Boolean fixWindows) [0x00008] in <7fc7c54b5e2d419395df064dc5addbb6>:0
at Xamarin.Forms.TemplatedItemsList`2[TView,TItem].OnProxyCollectionChanged (System.Object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x00000] in <7fc7c54b5e2d419395df064dc5addbb6>: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/5024/152b654a/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/5024/152b654a/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/5024/152b654a/source/xamarin-macios/src/UIKit/UIApplication.cs:63
at Mobile.Inspections.iOS.Application.Main (System.String[] args) [0x00002] in C:\Projects\...iOS\Main.cs:22