Using client = New HttpClient()
Dim task = client.SendAsync(request)
Dim response1 = Await 'task(of system.net.http.httpresponsemessage)
Dim response = Await client.SendAsync(request) ' object?
If response.IsSuccessStatusCode Then 'this cause late binding error because response is of type object and hence doesn't support issuccessstatuscode
'{"Success":true,"Error":null,"Data":[{"CurrencyId":2,"Symbol":"DOT","Total":9646.07411016,"Available":9646.07411016,"Unconfirmed":0.0,"HeldForTrades":0.0,"PendingWithdraw":0.0,"Address":"1HEfio1kreDBgj5uCw4VHbEDSgc6YJXfTN","Status":"OK","StatusMessage":null}]}
Console.WriteLine(Await response.Content.ReadAsStringAsync())
End If
End Using
我想知道为什么。
我认为响应类型和响应1应该是
system.net.http.httpresponsemessage
为什么它只是反对?
我认为await运算符会将task(of something)
转为something
。
最重要的是我
Option Explicit On
Option Strict On
Option Infer On
这是一个截图,其中悬停提示说响应1的类型是对象
以下是视觉工作室抱怨后期绑定的截图,因为response1的类型是对象
这是一个截图,我没有system.thread程序集可用。实际上,只有一个程序集以system.t开始...是系统事务
答案 0 :(得分:2)
问题似乎是该项目的目标是.NET 4.0,在这种情况下,如果没有对System.Threading.Tasks.dll的引用,则无法访问Task
和Task(Of T)
类型。 .NET 4.5及更高版本在mscorlib.dll中声明这些类型。