wpf 命名空间“System.Net”中不存在类型或命名空间名称“Http”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24120543/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
The type or namespace name 'Http' does not exist in the namespace 'System.Net'
提问by user3100575
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,
我正在 .net framework 3.5 中开发手机应用程序,它使用 API 服务调用来检查来自网站的电子邮件地址。我正在使用以下代码来执行该操作,
using System.Net.Http;
HttpClient webClient = new HttpClient();
webClient.QueryString.Add("email", email);
Stream stream = webClient.OpenRead(brandEndPoint);
Initially i used WebClientinstead of HttpClientand i got this error "The type or namespace name 'WebClient' could not be found" google and fixed this with HttpClient.
最初我使用WebClient而不是,HttpClient我得到了这个错误“ The type or namespace name 'WebClient' could not be found”谷歌并用HttpClient.
After replacing WebClientwith HttpClienti am getting this error "The type or namespace name 'Http' does not exist in the namespace 'System.Net".
替换后WebClient,HttpClient我收到此错误“ The type or namespace name 'Http' does not exist in the namespace 'System.Net”。
Need help to solve this.
需要帮助来解决这个问题。
Thanks
谢谢
采纳答案by Panagiotis Kanavos
HttpClientis available in .NET 4.5 or 4.0 with the Microsoft.Net.HttpNuGet package. It isn't at all available for .NET 3.5.
HttpClient可在 .NET 4.5 或 4.0 中使用Microsoft.Net.HttpNuGet 包。它根本不适用于 .NET 3.5。
HttpClientuses features like the TPL that are only available in .NET 4+.
HttpClient使用仅在 .NET 4+ 中可用的 TPL 等功能。
You'll have to use either System.Net.WebClientor a WebRequest. If you get any compilation errors, make sure you've added the proper usingstatements. These two classes are available since .NET 1.1, in the System.dlllibrary and thus are always available.
您必须使用System.Net.WebClient或WebRequest。如果出现任何编译错误,请确保添加了正确的using语句。从 .NET 1.1 开始,这两个类在System.dll库中可用,因此始终可用。

