2017-01-26 11 views
0

Xamarin.Formsアプリが特定のページを開くとクラッシュするクラッシュは再現可能ですが、リリースモードでのみ発生します。ビルドし、デバッグモードでアプリケーションを実行すると、同じページが正常に開きます。Xamarin.FormsアプリがInitializeComponentのFileNotFoundExceptionでクラッシュする

私はいくつかの努力を払って、アプリケーションが閉じられる前に、例外をキャッチしてスタックトレースをメッセージウィンドウに表示することができました。

System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime' or one of its dependencies 
File name: 'System.Runtime' 
    at System.AppDomain.Load (System.Reflection.AssemblyName assemblyRef, System.Security.Policy.Evidence assemblySecurity) 
    at System.AppDomain.Load (System.Reflection.AssemblyName assemblyRef) 
    at (wrapper remoting-invoke-with-check) System.AppDomain:Load (System.Reflection.AssemblyName) 
    at System.Reflection.Assembly.Load (System.Reflection.AssemblyName assemblyRef) 
    at Xamarin.Forms.Xaml.XamlParser.GetElementType (Xamarin.Forms.Xaml.XmlType xmlType, IXmlLineInfo xmlInfo, System.Reflection.Assembly currentAssembly, Xamarin.Forms.Xaml.XamlParseException& exception) 
    at Xamarin.Forms.Xaml.CreateValuesVisitor.Visit (Xamarin.Forms.Xaml.ElementNode node, INode parentNode) 
    at Xamarin.Forms.Xaml.ElementNode.Accept (IXamlNodeVisitor visitor, INode parentNode) 
    at Xamarin.Forms.Xaml.RootNode.Accept (IXamlNodeVisitor visitor, INode parentNode) 
    at Xamarin.Forms.Xaml.XamlLoader.Visit (Xamarin.Forms.Xaml.RootNode rootnode, Xamarin.Forms.Xaml.HydratationContext visitorContext) 
    at Xamarin.Forms.Xaml.XamlLoader.Load (System.Object view, System.String xaml) 
    at Xamarin.Forms.Xaml.XamlLoader.Load (System.Object view, System.Type callingType) 
    at Xamarin.Forms.Xaml.Extensions.LoadFromXaml[TXaml] (Xamarin.Forms.Xaml.TXaml view, System.Type callingType) 
    at MyApp.MyNamespace.Pages.MyPage.InitializeComponent() 
    at MyApp.MyNamespace.Pages.MyPage..ctor() 

答えて

2

私のコードはSystem.Runtime関連の輸入品の多くが、スタックトレースを持つ:コアエラーがどこかに私のページがInitializeComponentメソッドを呼び出したときに実行さXamlLoaderXamlParserSystem.RuntimeアセンブリのためのFileNotFoundExceptionのようですXAMLに問題があることを示して、実際の問題を見つけることができました。

問題は、そのページの汎用ビューで、type引数は "system:String"でした。

ReSharperのの System.Runtimeアセンブリの輸入にこれを自動完了

<mp:MyPage x:Class="MyApp.MyNamespace.Pages.MyPage" 
      xmlns="http://xamarin.com/schemas/2014/forms" 
      xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" 
      xmlns:mc="clr-namespace:MyApp.MyNamespace.Controls;assembly=MyApp" 
      xmlns:mp="clr-namespace:MyApp.MyNamespace.Pages;assembly=MyApp" 
      xmlns:system="clr-namespace:System;assembly=System.Runtime"> 
    <!-- ... --> 
    <mc:MyControl x:TypeArguments="system:String" /> 
    <!-- ... --> 
</mp:MyPage> 

これはいくつかの理由でデバッグモードで動作しますが、宣言はときにアプリが言及したエラーでクラッシュし、リリースモードでページを作成します。

<mp:MyPage x:Class="MyApp.MyNamespace.Pages.MyPage" 
      xmlns="http://xamarin.com/schemas/2014/forms" 
      xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" 
      xmlns:mc="clr-namespace:MyApp.MyNamespace.Controls;assembly=MyApp" 
      xmlns:mp="clr-namespace:MyApp.MyNamespace.Pages;assembly=MyApp" 
      xmlns:system="clr-namespace:System;assembly=mscorlib"> 
    <!-- ... --> 
    <mc:MyControl x:TypeArguments="system:String" /> 
    <!-- ... --> 
</mp:MyPage> 
:私は mscorlibにアセンブリを変更した場合、アプリはデバッグ リリースモードで働いていました
関連する問題