我有两个项目,都是.NET Framework 4.7.2。
在两个项目中,我的Imports
语句都是相同的。
Imports System.IO
Imports System.Net
Imports System.Security.Cryptography
Imports System.Text
Imports System.Net.NetworkInformation
Imports System.Net.Http
较旧的项目可以识别HttpClient
,但是较新的项目则不能...
Public Async Function getQueryURL(url As String) As Threading.Tasks.Task
Dim hc As HttpClient
hc = New HttpClient
Dim strServerInfo As String = ""
Dim result As String = ""
Dim rm As HttpResponseMessage()
rm = Await hc.GetAsync(url)
If rm.IsSuccessStatusCode Then
Dim res As String
res = Await rm.Content.ReadAsStringAsync()
result = res
End If
End Function
破碎的项目想导入(快速refaktor)
Imports Windows.Web.Http
答案 0 :(得分:-2)
禁止进口
Imports Windows.Web.Http
我必须在项目中引用System.Net.Http的路径
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.Net.Http.dll then it works... it does not work automatically
然后该项目使用正确的扩展版本von Windows.Web.Http
Imports Windows.Net.Http