2017-01-26 1 views
0

내 페이지가 열리면 내 Xamarin.Forms 앱이 계속 충돌합니다. 크래시는 재현 가능하지만 릴리스 모드에서만 발생합니다. 빌드 및 디버그 모드에서 응용 프로그램을 실행할 때 동일한 페이지가 잘 열립니다.Xamarin.Forms 응용 프로그램이 InitializeComponent의 FileNotFoundException과 충돌합니다.

일부 노력으로 나는 예외를 잡아 내고 앱이 닫히기 전에 메시지 창에 스택 추적을 표시했습니다. 핵심 오류 내 페이지가 InitializeComponent 메소드를 호출 할 때 조립 어딘가에 실행 XamlLoaderXamlParserSystem.Runtime에 대한 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 관련 수입을 많이 가지고,하지만 스택 추적 XAML에있는 문제가 실제 문제를 찾을 수 있음을 나타냅니다.

문제는 형식 인수가 "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에 어셈블리를 변경하는 경우, 응용 프로그램은 디버그 릴리스 모드에서 일
관련 문제