2016-11-12 15 views
1

このエラーが発生しているので、基本的にすべてのコードをthis tutorialからコピーしました。なぜここでは機能しないのか分かりません。Xamarinフォーム: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> 

答えて

0

わからない、これは誤植ではなく、タグ<p:ListDataPage>

1

を閉じていない場合、私は同じ問題を経験し、また、明示的に指示に従っています。

<ResourceDictionary MergedWith="mytheme:DarkThemeResources"/> は何らかの方法で失敗し、結果としてAppオブジェクトを未定義のままにしています。 私はこれがXamarin.Forms.Themesのバグだと思っています。解決する必要があるテーマ。私の理解は「プレリリース」バージョンなので、おそらくまだ信頼できません。

その他... Xamarinの新しい空のクロスプラットフォームテンプレートで作成された既定の参照を使用して、新しい空のXamarinフォームプロジェクト(VS2015)でテーマ機能をテストしました。これはXamarin.FormsとXamarin.forms.pagesバージョン2.3.0.38-pre2(私の場合)を参照しています。テーマはこれらの参考文献で動作します。

最新のNugetアップデートをFormsとPages(2.3.3.168)に適用すると、Themesプレビューは機能しなくなり、同じエラーが再現されます。 Xamarin.Forms.Themesは、Xamarinの最新リリースアセンブリでは動作しません。

0

Xamarin.Forms 2.3.3.168にアップデートした後、Xamarin.Forms.Themes 1.0.0.43-pre1でアプリがクラッシュしたことがあります。これはAndroidのみにあるので、この問題がiOSやWPビルドでも発生しているかどうかはわかりません。私はXamarin.Forms 2.3.3.152-pre2からアップグレードしましたが、うまくいきました。今の

<prism:PrismApplication xmlns="http://xamarin.com/schemas/2014/forms" 
     xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" 
     xmlns:prism="clr-namespace:Prism.Unity;assembly=Prism.Unity.Forms" 
     xmlns:mytheme="clr-namespace:Xamarin.Forms.Themes;assembly=Xamarin.Forms.Theme.Light" 
     x:Class="myApp.App"> 
    <Application.Resources> 
     <!-- Xamarin.Forms.Themes 1.0.0.43-pre1 is broken with Xamarin.Forms 2.3.3.168 --> 
     <!--<ResourceDictionary MergedWith="mytheme:LightThemeResources">--> 
     <ResourceDictionary> 
      <!-- theme definitions --> 
     </ResourceDictionary> 
    </Application.Resources> 
</prism:PrismApplication> 

マイソリューションは修正がリリースされるまでXamarin.Forms.Themeに"MergedWith"参照を削除することです。あるいは、XFのバージョンをThemesパッケージと互換性のあるものにロールバックすることもできます。

関連する問題