我在VS2010中创建了一个使用RestSharp发送电子邮件的功能。如果我使用client.Execute然后它工作正常,但如果我使用client.ExecuteAsync然后它给出错误。
Dim client As New RestSharp.RestClient()
client.BaseUrl = New Uri("URL").ToString()
client.Authenticator = New HttpBasicAuthenticator("test", "test")
Dim request As New RestRequest()
request.AddParameter("from", "test@xyz.com")
request.AddParameter("to", "abc@xyz.com")
request.AddParameter("subject", "Test Email")
request.AddParameter("html", "This is the test email.")
request.Method = Method.POST
client.ExecuteAsync(Request, Sub(res)
output_txt.Text = res.Content
End Sub)
我收到以下错误:
错误92重载解析失败,因为无法访问 可以使用以下参数调用'ExecuteAsync':'Public Overridable 函数ExecuteAsync(Of T)(请求为RestSharp.IRestRequest, 回调作为System.Action(Of RestSharp.IRestResponse(Of T), RestSharp.RestRequestAsyncHandle))As RestSharp.RestRequestAsyncHandle':类型参数'T'不能 推断。 '公共可覆盖函数ExecuteAsync(请求为 RestSharp.IRestRequest,回调As System.Action(Of RestSharp.IRestResponse,RestSharp.RestRequestAsyncHandle))As RestSharp.RestRequestAsyncHandle':嵌套的sub没有 与委托'System.Action(Of。)兼容的签名 RestSharp.IRestResponse,RestSharp.RestRequestAsyncHandle)'。延期 方法'Public Function ExecuteAsync(Of T)(请求为 RestSharp.IRestRequest,回调As System.Action(Of RestSharp.IRestResponse(Of T)))作为RestSharp.RestRequestAsyncHandle' 在'RestSharp.RestClientExtensions'中定义:类型参数'T'不能 推断出来。