Xamarin.forms 如何排除与Xamarin Xaml相关的运行时错误?

Xamarin.forms 如何排除与Xamarin Xaml相关的运行时错误?,xamarin.forms,Xamarin.forms,呵呵,长时间阅读,第一次发帖 我的简短问题是,有没有一种简单的方法可以在Xamarin中发现XAML的问题?Xaml编译并没有削减它 我的一个长长的问题——我刚刚花了一天大部分时间在Xamarin中的XAML错误中挣扎。通过一些认真的尝试和错误,本质上多次分解应用程序,最终在我的XAML中找到错误。事后再看问题,从我掌握的信息来看,我真的看不出我能找到问题 违规代码- <TableView Intent="Form"> <TableRoot>

呵呵,长时间阅读,第一次发帖

我的简短问题是,有没有一种简单的方法可以在Xamarin中发现XAML的问题?Xaml编译并没有削减它

我的一个长长的问题——我刚刚花了一天大部分时间在Xamarin中的XAML错误中挣扎。通过一些认真的尝试和错误,本质上多次分解应用程序,最终在我的XAML中找到错误。事后再看问题,从我掌握的信息来看,我真的看不出我能找到问题

违规代码-

    <TableView Intent="Form">
    <TableRoot>
        <TableSection Title="Name" >
            <EntryCell Label="First Name" Text="{Binding FirstName}"/>
            <EntryCell Label="Last Name"  Text="{Binding LastName}"/>
        </TableSection>
        <TableSection Title="Contact">
            <EntryCell Label="Phone" Text="{Binding PhoneNumber}"/>
            <EntryCell Label="Email" Text="{Binding Email}"/>
            <SwitchCell Text="Blocked" IsEnabled="{Binding IsBlocked}" />
        </TableSection>
    </TableRoot>
此错误确实指定了出现错误的页面
ContactDetailPage
,但也指定了创建该页面的页面
ContactPage
。我在VS2017中使用了调试器,但只得到了一个未处理的异常。还尝试使用UWP构建进行故障排除,但收到的信息更少。(怎么找到它?!?)

在中断了15年之后,我最近才再次编写代码,这只是教程练习,但肯定有更简单的方法


提前感谢:D

看来这条信息就是它的要点;System.ArrayTypeMismatchException:试图以与数组不兼容的类型访问元素。是的,我对此进行了一段时间的思考,但IsEnabled仍然是一个布尔值。类型匹配吗?。但我想它可能无法装订?这就是你认为XAML中存在问题的原因吗?异常和XAML似乎是两个不同的问题。完全删除行,并添加正确的属性阻止了错误的发生。这是我的观点。Xaml一旦通过编译,就很难排除故障。
    04-18 13:49:27.395  4219  4219 E AndroidRuntime: FATAL EXCEPTION: main
04-18 13:49:27.395  4219  4219 E AndroidRuntime: Process: ContactBookApp.Android, PID: 4219
04-18 13:49:27.395  4219  4219 E AndroidRuntime: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
04-18 13:49:27.395  4219  4219 E AndroidRuntime:        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
04-18 13:49:27.395  4219  4219 E AndroidRuntime: Caused by: java.lang.reflect.InvocationTargetException
04-18 13:49:27.395  4219  4219 E AndroidRuntime:        at java.lang.reflect.Method.invoke(Native Method)
04-18 13:49:27.395  4219  4219 E AndroidRuntime:        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
04-18 13:49:27.395  4219  4219 E AndroidRuntime:        ... 1 more
04-18 13:49:27.395  4219  4219 E AndroidRuntime: Caused by: android.runtime.JavaProxyThrowable: System.ArrayTypeMismatchException: Attempted to access an element as a type incompatible with the array.
04-18 13:49:27.395  4219  4219 E AndroidRuntime:   at (wrapper stelemref) System.Object:virt_stelemref_class (intptr,object)
04-18 13:49:27.395  4219  4219 E AndroidRuntime:   at System.Collections.Generic.List`1[T].Insert (System.Int32 index, T item) [0x0005f] in <8c304e4006094a46a7950338a3b3cb5d>:0
04-18 13:49:27.395  4219  4219 E AndroidRuntime:   at System.Collections.ObjectModel.Collection`1[T].InsertItem (System.Int32 index, T item) [0x00000] in <8c304e4006094a46a7950338a3b3cb5d>:0
04-18 13:49:27.395  4219  4219 E AndroidRuntime:   at System.Collections.ObjectModel.ObservableCollection`1[T].InsertItem (System.Int32 index, T item) [0x00006] in <8dac28ffb2cb41cba0b572038da86c99>:0
04-18 13:49:27.395  4219  4219 E AndroidRuntime:   at System.Collections.ObjectModel.Collection`1[T].Add (T item) [0x00023] in <8c304e4006094a46a7950338a3b3cb5d>:0
04-18 13:49:27.395  4219  4219 E AndroidRuntime:   at Xamarin.Forms.TableSectionBase`1[T].Add (T item) [0x00000] in <42fe931976e64c199eddde45068a6c09>:0
04-18 13:49:27.395  4219  4219 E AndroidRuntime:   at ContactBookApp.ContactDetailPage.InitializeComponent () [0x005f4] in <69ecbdf8eeeb43588bf41fa5db9c9afb>:0
04-18 13:49:27.395  4219  4219 E AndroidRuntime:   at ContactBookApp.ContactDetailPage..ctor (ContactBookApp.Contact contact) [0x0001b] in <69ecbdf8eeeb43588bf41fa5db9c9afb>:0
04-18 13:49:27.395  4219  4219 E AndroidRuntime:   at ContactBookApp.ContactsPage+<Contacts_ItemSelected>d__1.MoveNext () [0x00066] in <69ecbdf8eeeb43588bf41fa5db9c9afb>:0
04-18 13:49:27.395  4219  4219 E AndroidRuntime: --- End of stack trace from previous location where exception was thrown ---