当我打开特定页面时,我的 Xamarin.Forms 应用程序不断崩溃。崩溃是可重现的,但仅限于发布模式。当我在调试模式下构建和运行应用程序时,相同的页面可以正常打开。
经过一番努力,我设法在应用程序关闭之前捕获了异常并在消息窗口中显示堆栈跟踪。核心错误似乎是我的页面调用该方法时运行的某处FileNotFoundException
的程序集:System.Runtime
XamlParser
XamlLoader
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 ()