【问题标题】:Carousel view Xamarin forms give 2 errors轮播视图 Xamarin 表单给出 2 个错误
【发布时间】:2018-01-17 20:40:33
【问题描述】:

我从 Nuget 安装了 Xamarin Forms Carousel 视图

但是我收到 2 个错误:

1) 无法解析程序集:'Xamarin.Forms.CarouselView, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'

2) “ResolveLibraryProjectImports”任务意外失败。 System.IO.FileNotFoundException:无法加载程序集“MashamApp,版本=0.0.0.0,文化=中性,PublicKeyToken=”。也许它在 Mono for Android 配置文件中不存在?

<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
         xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"             
         xmlns:control="clr-namespace:Xamarin.Forms;assembly=Xamarin.Forms.CarouselView"
         x:Class="MashamApp.MainPage" BackgroundColor="#ff1b74bb">

<Grid x:Name="gMain" BackgroundColor="#ffebf6ff">

    <Grid.RowDefinitions>
        <RowDefinition Height="1*"></RowDefinition>
        <RowDefinition Height="1*"></RowDefinition>
        <RowDefinition Height="1*"></RowDefinition>
        <RowDefinition Height="1*"></RowDefinition>
    </Grid.RowDefinitions>

    <Grid Grid.Row="0">
        <Label x:Name="lblName" HorizontalTextAlignment="Center" VerticalTextAlignment="Center" FontSize="Medium"  TextColor="White"></Label>
    </Grid>

    <Grid Grid.Row="1">
        <control:CarouselView ItemsSource="{Binding MyDataSource}">
            <control:CarouselView.ItemTemplate>
                <DataTemplate>
                    <Label Text="{Binding LabelText}" />
                </DataTemplate>
            </control:CarouselView.ItemTemplate>
        </control:CarouselView>
    </Grid>

【问题讨论】:

  • 您是否在所有项目(即共享项目和 Android 项目)中都安装了 NuGet 包?

标签: c# xamarin xamarin.forms


【解决方案1】:

我不能推荐任何代码更改,因为您的代码看起来不错,但是 Xamarin.Forms.CarouselView, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null 对我来说有点可疑。我建议的是确保你拥有所有 您的参考工作正常(项目中的参考没有黄色三角形)可以尝试使用 nu get 包管理器控制台命令重新安装所有包

Update-Package

您也可以将其限制为一个项目。

Update-Package -Project YourProjectName

如果您想将软件包重新安装到与以前安装的版本相同的版本,则可以将 -reinstall 参数与 Update-Package 命令一起使用。

Update-Package -reinstall

我从这个答案 How do I get NuGet to install/update all the packages in the packages.config? 中提取了一些内容。

希望这会有所帮助!如果不让我知道,我会删除答案(我必须使用答案,因为我无法在 50 代表以下发表评论)干杯!

【讨论】:

  • 好吧,所以显然这不是他们更改控件名称的答案
【解决方案2】:

好吧,似乎他们改变了命名空间的名称和控件的名称,代码应该是这样的:

<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
         xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"             
         xmlns:c="clr-namespace:CarouselView.FormsPlugin.Abstractions;assembly=CarouselView.FormsPlugin.Abstractions"
         x:Class="MashamApp.MainPage" BackgroundColor="#ff1b74bb">

<Grid x:Name="gMain" BackgroundColor="#ffebf6ff">

    <Grid.RowDefinitions>
        <RowDefinition Height="1*"></RowDefinition>
        <RowDefinition Height="1*"></RowDefinition>
        <RowDefinition Height="1*"></RowDefinition>
        <RowDefinition Height="1*"></RowDefinition>
    </Grid.RowDefinitions>

    <Grid Grid.Row="0">
        <Label x:Name="lblName" HorizontalTextAlignment="Center" VerticalTextAlignment="Center" FontSize="Medium"  TextColor="White"></Label>
    </Grid>

    <Grid Grid.Row="1">
        <c:CarouselViewControl x:Name="CaruselViewCon" ItemsSource="{Binding MyDataSource}">
            <c:CarouselViewControl.ItemTemplate>
                <DataTemplate>
                    <Image Source="{Binding LabelText}" TextColor="Black" />
                </DataTemplate>
            </c:CarouselViewControl.ItemTemplate>
        </c:CarouselViewControl>
    </Grid>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多