use*_*575 7 .net c# wpf visual-studio
我正在开发.net framework 3.5中的手机应用程序,它使用API服务调用来检查来自网站的电子邮件地址.我使用以下代码来执行该操作,
using System.Net.Http;
HttpClient webClient = new HttpClient();
webClient.QueryString.Add("email", email);
Stream stream = webClient.OpenRead(brandEndPoint);
Run Code Online (Sandbox Code Playgroud)
最初我使用WebClient而不是HttpClient和我得到这个错误" The type or namespace name 'WebClient' could not be found"谷歌和修复这个HttpClient.
替换WebClient后HttpClient我得到这个错误" 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等功能.
您必须使用System.Net.WebClient或WebRequest.如果出现任何编译错误,请确保添加了正确的using语句.自.NET 1.1以来,这两个类在System.dll库中可用,因此始终可用.
| 归档时间: |
|
| 查看次数: |
17471 次 |
| 最近记录: |