0
當我打開特定頁面時,Xamarin.Forms應用程序不斷崩潰。該崩潰是可重現的,但僅限於發佈模式。當我以調試模式構建並運行應用程序時,同一頁面可以正常打開。Xamarin.Forms應用程序在InitializeComponent中與FileNotFoundException崩潰
通過一些努力,我設法捕捉異常並在應用程序關閉之前在消息窗口中顯示堆棧跟蹤。核心錯誤似乎是爲System.Runtime
在運行XamlLoader
的XamlParser
裝配某處FileNotFoundException
當我的頁面調用InitializeComponent
方法:
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()