C# 使用System.Net.Http时出现HttpClient错误

C# 使用System.Net.Http时出现HttpClient错误,c#,xamarin,xamarin.ios,xamarin.forms,xamarin.mac,C#,Xamarin,Xamarin.ios,Xamarin.forms,Xamarin.mac,我得到以下错误 Error CS0246: The type or namespace name 'HttpClient' could not be found (are you missing a using directive or an assembly reference?) (CS0246) 但是,我的使用System.Net.Http并没有抛出错误 我用的是Xamarin-都是最新的 我已经清理了我的项目,更新了我的所有NUGET,并确保我的项目包含Microsoft.Net.Ht

我得到以下错误

Error CS0246: The type or namespace name 'HttpClient' could not be found (are you missing a using directive or an assembly reference?) (CS0246)
但是,我的
使用System.Net.Http
并没有抛出错误

我用的是Xamarin-都是最新的

我已经清理了我的项目,更新了我的所有NUGET,并确保我的项目包含Microsoft.Net.Http包

我的目标是iOS项目

参考以下内容

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Net;
using System.Net.Http;
using Newtonsoft.Json;
using Xamarin.Forms;
编辑:主项目包中缺少引用-如何修复此问题?

编辑:.Net程序集引用

检查点: 转到项目(PCL和iOS)的references文件夹。右键单击并检查System.Net.Http是否位于它们的对应位置


两者的引用中都应包含System.Net.Http

也许它需要安装System.net?我同时引用了System.net和System.net.Http(您的System.Net.Http是否在PCL(Xamarin项目)中?有时删除它们会有所帮助(右键单击->删除)然后再次添加nuget包。我在上面用我的主要项目引用的屏幕截图进行了编辑。1.右键单击引用文件夹2.选择编辑引用3.在.NET程序集选项卡下-添加System.NET.Http和System.NetI我看到旁边的System.NET.Http,但是,当我选择它时,菜单刚好关闭。这太奇怪了(我在原来的问题上加了一张图片。