[英]Cannot find System.Runtime assembly while initializing XAML Previewer
當我嘗試為Xamarin.Forms加載XAML預覽器時發生錯誤。
初始化渲染器時找不到System.Runtime
程序集(請參見屏幕截圖)。
目標框架: .Net Standart 2.0
。
已安裝的程序集: NetStandart.Library 2.0.3
, Xamarin.Forms 4.0.0.425677
。
XAML代碼:
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:XamarinLab"
x:Class="XamarinLab.MainPage"
Title="Authorization">
<ScrollView>
<AbsoluteLayout BackgroundColor="SkyBlue">
<Frame AbsoluteLayout.LayoutBounds="0.5, 0.5, -1, -1" AbsoluteLayout.LayoutFlags="PositionProportional" HasShadow="True" CornerRadius="15">
<StackLayout WidthRequest="150">
<Entry x:Name="LoginEntry" Placeholder="login"/>
<Entry x:Name="PasswordEntry" Placeholder="password" IsPassword="True"/>
<Button Text="Sign In" Clicked="OnLoginButtonClicked" HorizontalOptions="Center" VerticalOptions="CenterAndExpand" />
<Button Text="Sign Up" Clicked="OnRegisterButtonClicked" HorizontalOptions="Center" VerticalOptions="CenterAndExpand" />
</StackLayout>
</Frame>
<ActivityIndicator x:Name="Loading" Margin="5" Color="White" IsRunning="False" AbsoluteLayout.LayoutBounds=".5,0,100,40" AbsoluteLayout.LayoutFlags="PositionProportional"/>
</AbsoluteLayout>
</ScrollView>
</ContentPage>
錯誤:
根據您的描述,當您要使用xaml預覽器時會遇到一些問題。
從Xamarin.Forms的XAML預覽器中 ,可以檢查以下步驟:
XAML預覽器未顯示或顯示錯誤
預覽器可能需要一些時間才能啟動-您將看到“正在初始化渲染”,直到准備就緒為止。
嘗試關閉並重新打開XAML文件。
確保您的App類具有無參數構造函數。
檢查您的Xamarin.Forms版本-必須至少為Xamarin.Forms 3.6。 您可以通過NuGet更新到最新的Xamarin.Forms版本。
檢查您的JDK安裝-預覽Android至少需要JDK 8。
嘗試在if(!DesignMode.IsDesignModeEnabled)中將所有初始化的類包裝在頁面的C#代碼中。
您說您的xamarin.forms版本是4.0.0.425677,可以卸載並安裝其他版本(例如3.6)來重試嗎?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.