简体   繁体   中英

Unable to install System.Net.Http in Xamarin portable project

Hello I'm new to Xamarin, I'm trying to install the System.Net.Http to a Xamarin portable project using NuGet Package Manager. However, whenever I try to download it I get this error

Could not install package 'System.Net.Http 4.3.1'. You are trying to install this package into a project that targets '.NETPortable,Version=v4.5,Profile=Profile259', 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

I tried every possible version of the package with no use. Could anybody provide some assistance?

Actually the way I managed to solve this problem was weird I found a referenced assembly called

.NET --> right click View in object browser --> select System.Net.Http --> clicked add reference to the selected project

and the reference is added

Have you tried to install Microsoft.Net.Http ? I use it in my PCL Xamarin Forms apps.

This can be resolved by changing the profile number for the PCL project. Personally, i would untick all the unneeded target frameworks by going to: Project Options -> Build - General - Change Targets .

In my case i have unticked Windows Phone silverlight 8 and the profile number got changed from PCL 4.5 Profile 259 to PCL 4.5 Profile 111 as shown in this screenshot:

适用于Mac的Visual Studio 2017

After doing so System.Net.Http can be added easily.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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