【问题标题】:Xamarin.Forms Package ErorrXamarin.Forms 包错误
【发布时间】:2016-08-26 03:23:12
【问题描述】:

是否有人在通过“添加 NuGet 包” 选项添加 Xamarin.Forms 包 时遇到此错误?

PS 我正在使用 Xamarin Studio,我只在 Windows 上遇到过这种情况。

错误信息是:

无法安装包“Xamarin.Forms 2.2.0.31”。你正试图 将此包安装到目标项目中 '.NETFramework,Version=v4.5,Profile=Profile78',但包确实 不包含任何程序集引用或内容文件 与该框架兼容。

Here is the screenshot

【问题讨论】:

  • 您能说说您目前采取的步骤吗?您创建了什么类型的项目?
  • @Sreeraj,所以我所做的是使用 可移植类库 开发 Xamarin.Forms 应用程序。好像我的 PCL 有问题。

标签: xamarin nuget xamarin.forms nuget-package xamarin-studio


【解决方案1】:

您的配置文件具有可移植类Profile78。配置文件是可移植类的类型,您可以在其中选择可以使用 PCL 的目标项目。您选择的越多,提供的功能就越少。

您需要将其更改为另一个。通常大多数类(包括 Xamarin.Forms)都支持 Profile111。 Profile111 是在 Profile78 的 contast du Profile78 中不支持 Silverlight 的配置文件。因此,您需要转到“属性”并取消选择“Windows Phone Silverlight”和“Silverlight”。您可以选择其他所有内容(.Net 4.5、Windows 8、Windows Phone 8.1、Android、iOS/iOS 经典和 ASP.NET Core 1)。

然后尝试再次添加 Xamarin.Forms。

您可以通过所有(?)个人资料列表查看更多信息here

这里你看看如何在 Visual Studio 项目属性中改变:

这里是 Xamarin Studio 项目选项:

【讨论】:

  • 这可以使用 Xamarin Studio 实现吗?
  • 是的,您甚至可以更轻松地切换配置文件 ;)
  • Xamarin.Forms 2.2.0.31 支持 Profile78 并在 Windows 上的 Xamarin Studio 中成功安装。
【解决方案2】:

问题是您没有在 Windows 上安装可移植类库 (PCL) 配置文件。 Xamarin.Forms 2.2.0.31 支持 Profile78,因此将其更改为 Profile111 不会解决问题。

错误消息本身表明这是问题所在,因为它引用了 Profile78。如果 NuGet 包确实不兼容,那么 NuGet 将在其错误消息中显示 PCL 配置文件中的框架,而不是配置文件编号。如果我尝试将 Xamarin.Forms 2.2.0.31 安装到针对 Xamarin.Forms 不支持的 Profile1 的 PCL 项目中,则会出现错误:

Could not install package 'Xamarin.Forms 2.2.0.31'. You are trying to install this package into a project that targets 'portable-net40+sl40+win+wp+Xbox40', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.

请注意,没有提到 Profile1。

installing Portable Class Libraries for Xamarin Studio上有详细的说明,我在这里总结一下:

要在 Windows 上安装可移植类库,您有三个选择:

  1. 安装 Visual Studio 2013(完整版或 Express 版)。更新 2 或 以上为必填项。
  2. 安装Portable Library ToolsPortable Library Reference Assemblies 4.6
  3. 安装 Portable Library Tools 并将 .NETPortable 目录从 Mono 复制到 Windows。

【讨论】:

    猜你喜欢
    • 2018-06-30
    • 2021-04-11
    • 2021-10-02
    • 1970-01-01
    • 2020-07-11
    • 2019-03-30
    • 1970-01-01
    • 1970-01-01
    • 2021-12-11
    相关资源
    最近更新 更多