Xamarin.Forms Package Erorr

我的未来我决定 提交于 2019-12-25 05:24:10

问题


Has anyone encountered this error when adding the Xamarin.Forms package through the "Add NuGet package" option?

PS I'm using Xamarin Studio and I only encounter this with Windows.

Error message is:

Could not install package 'Xamarin.Forms 2.2.0.31'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.5,Profile=Profile78', but the package does not contain any assembly references or content files that are compatible with that framework.

Here is the screenshot


回答1:


You are having a profile which has portable class Profile78.Profiles are the type of your portable class where you select the target projects which can use your PCL. The more you select the less functionality can be provided.

You need to change it to another one. Usually most classes (including Xamarin.Forms) are supporting Profile111. Profile111 is a profile which does not support Silverlight in contast du Profile78. So you need to go to Properties and deselect Windows Phone Silverlight and Silverlight. You can select everything else (.Net 4.5, Windows 8, Windows Phone 8.1, Android, iOS/iOS classic and ASP.NET Core 1).

Then try adding Xamarin.Forms again.

You can see more information with a list of all(?) profiles here.

Here you see how to change in Visual Studio project Properties:

And here in Xamarin Studio project Option:




回答2:


The problem is that you do not have the Portable Class Library (PCL) profiles installed on Windows. Xamarin.Forms 2.2.0.31 supports Profile78 so changing it to Profile111 will not fix the problem.

The error message itself indicates that this is the problem since it refers to Profile78. If the NuGet package was really incompatible then NuGet would show the frameworks in the PCL profile in its error message not the profile number. If I try to install Xamarin.Forms 2.2.0.31 into a PCL project that targets Profile1 which is not supported by Xamarin.Forms then I get an error:

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.

Note that Profile1 is not mentioned.

There are detailed instructions on installing Portable Class Libraries for Xamarin Studio which I will summarize here:

To install the Portable Class Libraries on Windows you have three options:

  1. Install Visual Studio 2013 (full or Express version). Update 2 or above is required.
  2. Install the Portable Library Tools and the Portable Library Reference Assemblies 4.6.
  3. Install the Portable Library Tools and copy the .NETPortable directory from Mono over to Windows.


来源:https://stackoverflow.com/questions/36964193/xamarin-forms-package-erorr

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!