【问题标题】:Cannot find System.Runtime assembly while initializing XAML Previewer初始化 XAML 预览器时找不到 System.Runtime 程序集
【发布时间】:2019-10-10 01:41:16
【问题描述】:

当我尝试为 Xamarin.Forms 加载 XAML Previewer 时发生错误。

初始化渲染器时找不到System.Runtime 程序集(见屏幕截图)。

目标框架:.Net Standart 2.0.
已安装的程序集:NetStandart.Library 2.0.3Xamarin.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 预览器不稳定我使用大猩猩播放器

标签: c# xaml xamarin.forms xamarin-previewer


【解决方案1】:

根据您的描述,您在使用 xaml 预览器时遇到了一些问题。

来自XAML Previewer for Xamarin.Forms,您可以查看以下步骤:

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)重试

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-11-09
    • 1970-01-01
    • 2010-10-02
    相关资源
    最近更新 更多