名称空间’System.Net’中不存在类型或命名空间名称’Http’

我正在开发.net framework 3.5中的手机应用程序,该应用程序正在使用API​​服务调用来检查来自网站的电子邮件地址。我正在使用以下代码来执行该操作,

using System.Net.Http; HttpClient webClient = new HttpClient(); webClient.QueryString.Add("email", email); Stream stream = webClient.OpenRead(brandEndPoint); 

最初我使用WebClient而不是HttpClient ,我得到了这个错误“ The type or namespace name 'WebClient' could not be found ”google并使用HttpClient修复此问题。

HttpClient替换WebClient ,我收到此错误“ The type or namespace name 'Http' does not exist in the namespace 'System.Net

需要帮助来解决这个问题。

谢谢

HttpClient在.NET 4.5或4.0中可用,带有Microsoft.Net.Http NuGet包。 它完全不适用于.NET 3.5。

HttpClient使用仅在.NET 4+中可用的TPL等function。

您必须使用System.Net.WebClient或WebRequest 。 如果出现任何编译错误,请确保添加了正确的using语句。 自.NET 1.1以来,这两个类在System.dll库中可用,因此始终可用。