Nuget错误:无法添加对System.Net.Http的引用

don*_*lan 1 c# gmail-api

我收到一个错误:

"无法加载文件或程序集'System.Net.Http.Primitives,Version = 4.2.22.0,Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a'或其中一个依赖项.系统找不到指定的文件.":"System.Net .Http.Primitives,Version = 4.2.22.0,Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a"}

运行以下代码:

        base.Initialize(name, config);
        _emailAddress = Settings.EmailAddress;
        string clientSecret = Settings.ClientSecret;
        string clientId = Settings.ClientId;
        Task<UserCredential> tCredential;
        ClientSecrets clientSecrets = new ClientSecrets {ClientId = clientId, ClientSecret = clientSecret};
        tCredential = GoogleWebAuthorizationBroker.AuthorizeAsync(
            clientSecrets,
            Scopes,
            "user",
            CancellationToken.None);
        UserCredential credential;
        try
        {
            credential = tCredential.Result;
        }
        catch (Exception ex)
        {
            throw;
        }
        _service = new GmailService(new BaseClientService.Initializer()
        {
            HttpClientInitializer = credential,
            ApplicationName = "Draft Sender", //applicationName,
        });
Run Code Online (Sandbox Code Playgroud)

有关如何解决此错误的任何想法?

我尝试根据这个答案从Nuget更新Http客户端库的安装,但是无法安装错误:无法添加对System.Net.Http的引用,请确保它在全局程序集缓存中.我不知道全局程序集缓存是什么,或者如何确保它在那里.有这个问题的解决方案吗?

Mic*_*han 5

尝试通过转到工具 - >扩展和更新 - >更新 - > NuGet包管理器 - >更新来更新NuGet包管理器.

并卸载包并重新安装.