我正在.net Framework 3.5中开发手机应用程序,该应用程序使用API服务调用来检查来自网站的电子邮件地址。我正在使用以下代码执行该操作,
using System.Net.Http;
HttpClient webClient = new HttpClient();
webClient.QueryString.Add("email", email);
Stream stream = webClient.OpenRead(brandEndPoint);
最初我使用WebClient
而不是Google,并HttpClient
收到了这个错误The type or namespace name 'WebClient' could not be found
“ google”并用HttpClient
。
用替换后WebClient
,出现HttpClient
此错误“ The type or namespace name 'Http' does not exist in the namespace 'System.Net
”。
需要帮助解决此问题。
谢谢
HttpClient
在带有Microsoft.Net.Http NuGet包的.NET 4.5或4.0中可用。它根本不适用于.NET 3.5。
HttpClient
使用仅在.NET 4+中可用的TPL之类的功能。
您必须使用System.Net.WebClient或WebRequest。如果遇到任何编译错误,请确保已添加正确的using
语句。这两个类自.NET 1.1开始在System.dll
库中可用,因此始终可用。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句