简体   繁体   English

Xamarin.Forms无法安装包

[英]Xamarin.Forms could not install package

When creating a new solution within Xamarian studio I get this error 在Xamarian工作室中创建新解决方案时,我收到此错误

Could not install package 'Xamarin.Forms 1.0.6186'. 无法安装包'Xamarin.Forms 1.0.6186'。 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. 您正在尝试将此软件包安装到以“.NETFramework,Version = v4.5,Profile = Profile78”为目标的项目中,但该软件包不包含与该框架兼容的任何程序集引用或内容文件。 For more information, contact the package author. 有关更多信息,请与软件包作者联系。

Is there a certain version of .Net that Xamarian Forms requires for it to be included in the solution? Xamarian Forms是否需要某个版本的.Net才能将其包含在解决方案中? I've tried searching in their documentation but I'm only seeing marketing and not real in depth documentation. 我试过在他们的文档中搜索,但我只看到营销,而不是真正的深度文档。

I had a similar issue using Visual Studio and I've found that the following combination in the PCL works: 我使用Visual Studio遇到了类似的问题,我发现PCL中的以下组合有效:

  • .NET Framework 4.5 .NET Framework 4.5
  • Windows Phone Silverlight 8 Windows Phone Silverlight 8
  • Xamarin.Android Xamarin.Android
  • Xamarin.iOS Xamarin.iOS

You have created the wrong project type, you created a normal Windows app, and I assume you are targeting iOS/Android or Mac. 您创建了错误的项目类型,您创建了一个普通的Windows应用程序,我假设您的目标是iOS / Android或Mac。

Create the project with the correct type and it should work correctly. 使用正确的类型创建项目,它应该正常工作。

If you are using Xamarin Studio for Windows (without also having Visual Studio installed) you need to download the Portable Library Tools . 如果您使用的是Xamarin Studio for Windows(未安装Visual Studio),则需要下载可移植库工具 See the Xamarin doc Introduction to Portable Class Libraries . 请参阅Xamarin doc 可移植类库简介

I had the same problem with my Xamarin project. 我的Xamarin项目遇到了同样的问题。 The problem was, that in the portable Xamarin project Windows Phone Silverlight was set as target. 问题是,在便携式Xamarin项目中,Windows Phone Silverlight被设置为目标。 The PCL project from which I created the nuget, didn't reference Silverlight as target. 我创建nuget的PCL项目没有将Silverlight作为目标。 I don't need Silverlight, so uninstalling all nuget packages from my portable Xamarin project, removing silverlight as target and reinstalling the NuGet packages solved it. 我不需要Silverlight,所以从我的便携式Xamarin项目卸载所有nuget包,删除silverlight作为目标并重新安装NuGet包解决了它。

I had similar issue using VS and I found solution here - http://forums.xamarin.com/discussion/29674/xamarin-forms-dll-cannot-be-installed 我有类似的问题使用VS而我在这里找到了解决方案 - http://forums.xamarin.com/discussion/29674/xamarin-forms-dll-cannot-be-installed

"It looks like your NuGet Package Manager needs to be upgraded. The Xamarin PCL Profiles are installed but NuGet is not recognising Xamarin.iOS as a target framework. You can update NuGet by selecting Tools - Extensions and Updates, then select the Updates tab, then select Visual Studio Gallery. Then update NuGet from there." “看起来您的NuGet包管理器需要升级.Xamarin PCL配置文件已安装,但NuGet未将Xamarin.iOS识别为目标框架。您可以通过选择工具 - 扩展和更新来更新NuGet,然后选择更新选项卡,然后选择Visual Studio Gallery。然后从那里更新NuGet。“

I have invested a lot of time trying all the solutions posted here, but none of them helped me... Here is the solution that worked for me (on Windows 10): 我花了很多时间尝试在这里发布的所有解决方案,但没有一个帮助我......这是适用于我的解决方案(在Windows 10上):

1.) Open your .csproj file 1.)打开.csproj文件

2.) Find the TargetFrameworkProfile entry 2.)找到TargetFrameworkProfile条目

3.) This entry contains Profile78 for me, therefore I open the folder below 3.)此条目包含Profile78 ,因此我打开下面的文件夹

c:/Program Files (x86)/Reference Assemblies/Microsoft/Framework/.NETPortable/v4.5/Profile/Profile78/SupportedFrameworks c:/ Program Files(x86)/ Reference Assemblies / Microsoft / Framework / .NETPortable / v4.5 / Profile / Profile78 / SupportedFrameworks

4.a) If the folder does not exist, then use one of the solutions posted here to install the PLC right on your PC 4.A)如果文件夹不存在,然后用贴在这里的解决方案之一,以安装PLC在PC上的权利

4.b) Unfortunately, ASP.NET and Xamarin don't like each other, therefore delete all ASP profiles from this folder. 4.b)不幸的是,ASP.NET和Xamarin彼此不喜欢,因此从该文件夹中删除所有ASP配置文件。 For me it was ASP.NET Core 5.0.xml . 对我来说,它是ASP.NET Core 5.0.xml Obviously this will break your ASP.NET support in VS 显然这会打破VS中的ASP.NET支持

5.) Restart Xamarin and have fun! 5.)重启Xamarin,玩得开心!

interesting reading about all that: https://forums.xamarin.com/discussion/52846/cannot-create-new-xamarin-forms-project-pcl-in-xamarin-studio-win10-vs2015 有趣的阅​​读所有这些: https//forums.xamarin.com/discussion/52846/cannot-create-new-xamarin-forms-project-pcl-in-xamarin-studio-win10-vs2015

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM