简体   繁体   English

mscorlib.ni.dll中发生类型'System.Reflection.TargetInvocationException'的异常,但未在用户代码中处理:Xamarin形式

[英]An exception of type 'System.Reflection.TargetInvocationException' occurred in mscorlib.ni.dll but was not handled in user code: in Xamarin Form

I created the MasterDetailPage in Xamarin form but when i tried to run the app it gave me the above error. 我以Xamarin形式创建了MasterDetailPage,但是当我尝试运行该应用程序时,出现了以上错误。 Below is the Xaml code for my MasterDetailPage 以下是我的MasterDetailPage的Xaml代码

<?xml version="1.0" encoding="utf-8" ?>
<MasterDetailPage xmlns="http://xamarin.com/schemas/2014/forms"
         xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
         xmlns:pages="clr-namespace:App2;assembly=App2"
         x:Class="App2.ParentsMenuPage">
<MasterDetailPage.Master>
<pages:ParentMasterPage x:Name="masterPage" />
</MasterDetailPage.Master>
<MasterDetailPage.Detail>
<NavigationPage>
  <x:Arguments>
    <pages:ParentHomePage />
   </x:Arguments>
  </NavigationPage>
</MasterDetailPage.Detail>
</MasterDetailPage>


 The Xaml code for My Master Page is below


 <?xml version="1.0" encoding="utf-8" ?>
 <ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
         xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
         x:Class="App2.ParentMasterPage" Padding="0,40,0,0">
<ContentPage.Content>
<StackLayout VerticalOptions="FillAndExpand">
  <ListView x:Name="listView" VerticalOptions="FillAndExpand" SeparatorVisibility="None">
    <ListView.ItemTemplate>
      <DataTemplate>
        <ImageCell Text="{Binding Title}" ImageSource="{Binding IconSource}" />
      </DataTemplate>
    </ListView.ItemTemplate>
   </ListView>
  </StackLayout>
</ContentPage.Content>

The code-behind for the master page is below 母版页的代码如下

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using Xamarin.Forms;

namespace App2
{
public class ParentMasterItem
{
    public string Title { get; set; }
    public string IconSource { get; set; }
    public Type TargetType { get; set; }
}

public partial class ParentMasterPage : ContentPage
{
    public ListView ListView { get { return listView; } }

    public ParentMasterPage()
    {
        InitializeComponent();

        var masterPageItems = new List<ParentMasterItem>();
        masterPageItems.Add(new ParentMasterItem
        {
            Title = "Home",
            IconSource = "images/home-small.png",
            TargetType = typeof(ParentHomePage)
        });
        masterPageItems.Add(new ParentMasterItem
        {
            Title = "My Ward's",
            IconSource = "images/ward-small.png",
            TargetType = typeof(ParentWardsPage)
        });
        masterPageItems.Add(new ParentMasterItem
        {
            Title = "Chat",
            IconSource = "images/chat-small.png",
            TargetType = typeof(ParentChatPage)
        });

        listView.ItemsSource = masterPageItems;
       }
      }
    }

Then Detail Page 然后是详细页面

 <?xml version="1.0" encoding="utf-8" ?>
 <ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
         xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
         x:Class="App2.ParentHomePage">

 <ContentPage.Content>
   <StackLayout>
    <StackLayout.Children>
     <Frame OutlineColor="Accent">
       <Frame.Content>
         <StackLayout Orientation="Horizontal">
          <StackLayout.Children>
            <Label Text="Home Page"
                   VerticalOptions="Center" />
          </StackLayout.Children>
         </StackLayout>
       </Frame.Content>
     </Frame>

  </StackLayout.Children>
</StackLayout>
</ContentPage.Content>
</ContentPage>

Please can anyone help me figure out where the problem is 请任何人能帮助我找出问题所在

  1. MyMasterPage should have a Title. MyMasterPage应该有一个标题。
  2. Take in Consideration that inside the MasterDetailsPage.Master Tags the Content Page Should Have a Title. 考虑在MasterDetailsPage.Master标记内,内容页面应具有标题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 System.ni.dll中发生类型&#39;System.Reflection.TargetInvocationException&#39;的异常,但未在用户代码中处理 - An exception of type 'System.Reflection.TargetInvocationException' occurred in System.ni.dll but was not handled in user code mscorlib.dll中发生类型&#39;System.Reflection.TargetInvocationException&#39;的异常,但未在用户代码中处理 - An exception of type 'System.Reflection.TargetInvocationException' occurred in mscorlib.dll but was not handled in user code EntityFramework.SqlServer.dll中发生类型为&#39;System.Reflection.TargetInvocationException&#39;的异常,但未在用户代码中处理 - An exception of type 'System.Reflection.TargetInvocationException' occurred in EntityFramework.SqlServer.dll but was not handled in user code mscorlib.ni.dll中发生类型&#39;System.InvalidOperationException&#39;的异常,但未处理 - Exception of type 'System.InvalidOperationException' occurred in mscorlib.ni.dll but was not handled “ mscorlib.ni.dll中发生了&#39;System.ArgumentException&#39;类型的异常” - “An exception of type 'System.ArgumentException' occurred in mscorlib.ni.dll” System.Runtime.InteropServices.COMException发生在mscorlib.ni.dll中,但未在用户代码中处理 - System.Runtime.InteropServices.COMException occurred in mscorlib.ni.dll but was not handled in user code System.Windows.ni.dll Windows Phone 8中发生类型&#39;System.Reflection.TargetInvocationException&#39;的异常 - An exception of type 'System.Reflection.TargetInvocationException' occurred in System.Windows.ni.dll windows phone 8 发生时在Windows Phone中的System.Windows.ni.dll中发生类型为“&#39;System.Reflection.TargetInvocationException&#39;的未处理异常 - When it occurs An unhandled exception of type “'System.Reflection.TargetInvocationException' occurred in System.Windows.ni.dll” inWindows Phone mscorlib.ni.dll中发生类型为&#39;System.IO.FileNotFoundException&#39;的第一次机会异常-Windows Phone - A first chance exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.ni.dll - windows phone mscorlib:System.reflection.TargetInvocationException - mscorlib:System.reflection.TargetInvocationException
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM