我正在开发Android / iOS / UWP Xamarin.Forms应用。最近几周,我主要研究Android / iOS应用程序。现在,我想再次在UWP中启动我的应用程序并得到错误消息:
System.TypeLoadException
HResult=0x80131522
Message=Could not find Windows Runtime type 'Microsoft.Graphics.Canvas.UI.Xaml.CanvasImageSource'.
Source=Xamarin.Forms.Platform.UAP
StackTrace:
at Xamarin.Forms.Platform.UWP.ImageRenderer.GetDesiredSize(Double widthConstraint, Double heightConstraint)
at Xamarin.Forms.Platform.UWP.Platform.GetNativeSize(VisualElement element, Double widthConstraint, Double heightConstraint)
at Xamarin.Forms.Platform.UWP.WindowsBasePlatformServices.GetNativeSize(VisualElement view, Double widthConstraint, Double heightConstraint)
at Xamarin.Forms.VisualElement.OnSizeRequest(Double widthConstraint, Double heightConstraint)
at Xamarin.Forms.Image.OnSizeRequest(Double widthConstraint, Double heightConstraint)
at Xamarin.Forms.VisualElement.OnMeasure(Double widthConstraint, Double heightConstraint)
at Xamarin.Forms.VisualElement.GetSizeRequest(Double widthConstraint, Double heightConstraint)
at Xamarin.Forms.VisualElement.Measure(Double widthConstraint, Double heightConstraint, MeasureFlags flags)
at Xamarin.Forms.StackLayout.CalculateNaiveLayout(LayoutInformation layout, StackOrientation orientation, Double x, Double y, Double widthConstraint, Double heightConstraint)
at Xamarin.Forms.StackLayout.CalculateLayout(LayoutInformation layout, Double x, Double y, Double widthConstraint, Double heightConstraint, Boolean processExpanders)
at Xamarin.Forms.StackLayout.OnSizeRequest(Double widthConstraint, Double heightConstraint)
at Xamarin.Forms.VisualElement.OnMeasure(Double widthConstraint, Double heightConstraint)
at Xamarin.Forms.VisualElement.GetSizeRequest(Double widthConstraint, Double heightConstraint)
at Xamarin.Forms.Layout.GetSizeRequest(Double widthConstraint, Double heightConstraint)
at Xamarin.Forms.VisualElement.Measure(Double widthConstraint, Double heightConstraint, MeasureFlags flags)
at Xamarin.Forms.ScrollView.OnSizeRequest(Double widthConstraint, Double heightConstraint)
at Xamarin.Forms.VisualElement.OnMeasure(Double widthConstraint, Double heightConstraint)
at Xamarin.Forms.VisualElement.GetSizeRequest(Double widthConstraint, Double heightConstraint)
at Xamarin.Forms.Layout.GetSizeRequest(Double widthConstraint, Double heightConstraint)
at Xamarin.Forms.VisualElement.Measure(Double widthConstraint, Double heightConstraint, MeasureFlags flags)
at Xamarin.Forms.Layout.LayoutChildIntoBoundingRegion(VisualElement child, Rectangle region)
at Xamarin.Forms.Page.LayoutChildren(Double x, Double y, Double width, Double height)
at Xamarin.Forms.Page.UpdateChildrenLayout()
at Xamarin.Forms.Page.OnSizeAllocated(Double width, Double height)
at RA_Krypt.MainPage.OnSizeAllocated(Double width, Double height) in C:\Users\Christian\source\repos\Xamarin_RaKrypt\RA-Krypt\RA-Krypt\MainPage.xaml.cs:line 27
at Xamarin.Forms.Page.OnChildMeasureInvalidated(VisualElement child, InvalidationTrigger trigger)
at Xamarin.Forms.Page.OnChildMeasureInvalidated(Object sender, EventArgs e)
at Xamarin.Forms.VisualElement.InvalidateMeasureInternal(InvalidationTrigger trigger)
at Xamarin.Forms.VisualElement.set_IsNativeStateConsistent(Boolean value)
at Xamarin.Forms.Platform.UWP.VisualElementRenderer`2.OnControlLoaded(Object sender, RoutedEventArgs args)
我的应用程序根本无法启动。我已经重建了项目并重新启动了计算机,这有时对Xamarin有所帮助,但我仍然遇到问题。我该怎么做才能使我的应用程序再次运行?
答案 0 :(得分:4)
已报告并修复了该错误,请参见this issue on GitHub。该修复程序将包含在即将发布的Xamarin.Forms中。
目前有解决方法。确保您安装了最新版本的Xamarin.Forms。然后:
如果您需要支持Fall Creators Update(SDK 16299)
Win2D.uwp
软件包到您的UWP项目<DisableWin2DPlatformCheck>true</DisableWin2DPlatformCheck>
添加到UWP项目的csproj
如果您可以支持最低版本的SDK 17134
Win2D.uwp
软件包到您的UWP项目