C# HttpClient.GetAsync在一个类中工作,但在另一个类中不工作

C# HttpClient.GetAsync在一个类中工作,但在另一个类中不工作,c#,windows,web,uwp,httpclient,C#,Windows,Web,Uwp,Httpclient,这就是它的工作原理: public class ThisWorks : IPortableHttpClient { private Windows.Web.Http.HttpClient client; async public Task<Windows.Web.Http.HttpResponseMessage> GetAsync(Uri url) { return await client.GetAsync(url); } 另一个

这就是它的工作原理:

public class ThisWorks : IPortableHttpClient
{
    private Windows.Web.Http.HttpClient client;

    async public Task<Windows.Web.Http.HttpResponseMessage> GetAsync(Uri url)
    {
        return await client.GetAsync(url);
    }

另一个可能有用的信息是:它工作的代码在UWP框架中。它在.NET framework中不起作用。

我使用了错误的名称空间

我不得不将
Windows.Web.Http
更改为
System.Net.Http

public class DoesntWork : IPortableHttpClient
{
    private Windows.Web.Http.HttpClient client;

    async public Task<Windows.Web.Http.HttpResponseMessage> GetAsync(Uri url)
    {
        return await client.GetAsync(url);
    }
public interface IPortableHttpClient
{
    Task<HttpResponseMessage> GetAsync(Uri url);        
}