我不斷收到這個錯誤,我基本上覆制了this tutorial的所有代碼,所以我不明白爲什麼它不在這裏工作。Xamarin Forms:System.Reflection.TargetInvocationException
namespace BHASIVCBULLETIN1 {
using System;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
public partial class App : global::Xamarin.Forms.Application {
[System.CodeDom.Compiler.GeneratedCodeAttribute("Xamarin.Forms.Build.Tasks.XamlG", "0.0.0.0")]
private void InitializeComponent() {
--> this.LoadFromXaml(typeof(App));
}
}
}
以上是錯誤代碼,它是在運行時生成的。
<?xml version="1.0" encoding="UTF-8"?>
<p:ListDataPage xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:p="clr-namespace:Xamarin.Forms.Pages;assembly=Xamarin.Forms.Pages"
x:Class="BHASIVCBULLETIN1.LinkerPage"
Title="Sessions" StyleClass="Events">
<p:ListDataPage.DataSource>
<p:JsonDataSource Source="http://demo3143189.mockable.io/sessions" />
</p:ListDataPage.DataSource>
這是鏈接的網頁代碼
using System;
using System.Collections.Generic;
using Xamarin.Forms.Pages;
using Xamarin.Forms;
namespace BHASIVCBULLETIN1
{
public partial class LinkerPage : Xamarin.Forms.Pages.ListDataPage
{
public LinkerPage()
{
InitializeComponent();
}
}
}
這是我主要的應用程序的C#代碼
using Xamarin.Forms;
using System.Collections.Generic;
namespace BHASIVCBULLETIN1 {
public partial class App : Application
{
public App()
{
InitializeComponent();
MainPage = new NavigationPage(new LinkerPage());
}
protected override void OnStart()
{
// Handle when your app starts
}
protected override void OnSleep()
{
// Handle when your app sleeps
}
protected override void OnResume()
{
// Handle when your app resumes
}
}
}
這是我的主要應用程序的XML代碼
<Application xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:mytheme="clr-namespace:Xamarin.Forms.Themes;assembly=Xamarin.Forms.Theme.Dark"
x:Class="BHASIVCBULLETIN1.App">
<Application.Resources>
<!-- Application resource dictionary -->
<ResourceDictionary MergedWith="mytheme:DarkThemeResources" />
<!-- above xml code rferences the datapages nuget packages and resources that allow the methods to be used to create the GUI-->
</Application.Resources>
</Application>