Generics 异步返回异常时找不到C#方法

Generics 异步返回异常时找不到C#方法,generics,asynchronous,exception,missingmethodexception,Generics,Asynchronous,Exception,Missingmethodexception,我在尝试调用以下方法时收到一个异常(找不到方法) public static async Task<HttpResponseMessage> Send(HttpRequestMessage request) { ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; HttpResponseMessage response = await HttpClient.S

我在尝试调用以下方法时收到一个异常(找不到方法)

    public static async Task<HttpResponseMessage> Send(HttpRequestMessage request) {

        ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

        HttpResponseMessage response = await HttpClient.SendAsync(request);

        if (response.IsSuccessStatusCode)
            return response;

        throw new HttpResponseException(response);
    }

找到了该方法

我想了解在尝试引发异常时找不到该方法的具体原因(generic/async/TaskAwaiter无法匹配所有代码路径?)

您能推荐我如何以正确抛出异常的方式编写方法吗


谢谢你的帮助

结果证明这是一个骗局。问题与方法签名、泛型或异步操作无关。这是一个.Net标准版本控制问题,如下所述:

添加以下绑定重定向解决了此问题:

  <dependentAssembly>
    <assemblyIdentity name="System.Net.Http" culture="neutral" publicKeyToken="b03f5f7f11d50a3a" />
    <bindingRedirect oldVersion="0.0.0.0-4.2.0.0" newVersion="4.2.0.0" />
  </dependentAssembly>

结果证明这是一个骗局。问题与方法签名、泛型或异步操作无关。这是一个.Net标准版本控制问题,如下所述:

添加以下绑定重定向解决了此问题:

  <dependentAssembly>
    <assemblyIdentity name="System.Net.Http" culture="neutral" publicKeyToken="b03f5f7f11d50a3a" />
    <bindingRedirect oldVersion="0.0.0.0-4.2.0.0" newVersion="4.2.0.0" />
  </dependentAssembly>

  <dependentAssembly>
    <assemblyIdentity name="System.Net.Http" culture="neutral" publicKeyToken="b03f5f7f11d50a3a" />
    <bindingRedirect oldVersion="0.0.0.0-4.2.0.0" newVersion="4.2.0.0" />
  </dependentAssembly>