命名空间“System.Net"中不存在类型或命名空间名称“Http" [英] The type or namespace name 'Http' does not exist in the namespace 'System.Net'
问题描述
我正在 .net framework 3.5 中开发手机应用程序,它使用 API 服务调用来检查来自网站的电子邮件地址.我正在使用以下代码来执行该操作,
I am developing a handset application in .net framework 3.5,which is using an API service call to check the email address from website.I am using the below code to perform that,
using System.Net.Http;
HttpClient webClient = new HttpClient();
webClient.QueryString.Add("email", email);
Stream stream = webClient.OpenRead(brandEndPoint);
最初我使用 WebClient
而不是 HttpClient
并且我收到此错误找不到类型或命名空间名称 'WebClient'
"google 并使用 HttpClient
修复了这个问题.
Initially i used WebClient
instead of HttpClient
and i got this error "The type or namespace name 'WebClient' could not be found
" google and fixed this with HttpClient
.
将 WebClient
替换为 HttpClient
后,我收到此错误命名空间 'System.Net<中不存在类型或命名空间名称 'Http'/code>".
After replacing WebClient
with HttpClient
i am getting this error "The type or namespace name 'Http' does not exist in the namespace 'System.Net
".
需要帮助来解决这个问题.
Need help to solve this.
谢谢
推荐答案
HttpClient
可在 .NET 4.5 或 4.0 中使用 Microsoft.Net.Http NuGet 包.它根本不适用于 .NET 3.5.
HttpClient
is available in .NET 4.5 or 4.0 with the Microsoft.Net.Http NuGet package. It isn't at all available for .NET 3.5.
HttpClient
使用 TPL 等仅在 .NET 4+ 中可用的功能.
HttpClient
uses features like the TPL that are only available in .NET 4+.
您必须使用 System.Net.WebClient 或WebRequest.如果出现任何编译错误,请确保添加了正确的 using
语句.从 .NET 1.1 开始,这两个类在 System.dll
库中可用,因此始终可用.
You'll have to use either System.Net.WebClient or a WebRequest. If you get any compilation errors, make sure you've added the proper using
statements. These two classes are available since .NET 1.1, in the System.dll
library and thus are always available.
这篇关于命名空间“System.Net"中不存在类型或命名空间名称“Http"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!