';System.AggregateException';尝试使用Google API进行身份验证时,在ms

本文关键字:身份验证 ms AggregateException System Google API | 更新日期: 2023-09-27 18:23:48

我正在尝试使用Google日历API为自己制作一个小日历应用程序。我正在使用C#和.NET。基本上,我所做的只是从这里复制示例代码并从此处添加了FileDataStore类在Google Developers Console中创建了一个项目,为日历启用了API,通过NuGet安装了库,等等。所以我的代码现在看起来是这样的:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Google;
using Google.Apis.Auth.OAuth2;
using Google.Apis.Calendar.v3;
using Google.Apis.Calendar.v3.Data;
using Google.Apis.Services;
namespace calendar
{
public partial class Form1 : Form
{
    public Form1()
    {
        UserCredential credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
            new ClientSecrets
            {
                ClientId = "here's my client id",
                ClientSecret = "and the secret",
            },
            new[] { CalendarService.Scope.Calendar },
            "user",
            System.Threading.CancellationToken.None).Result;
        // Create the service.
        var service = new CalendarService(new BaseClientService.Initializer()
        {
            HttpClientInitializer = credential,
            ApplicationName = "Calendar API Sample",
        });
        InitializeComponent();
    }
}
}

但当我试图构建它时,它崩溃了,第一行(UserCredential凭据=…)的mscorlib.dll中出现了"System.AggregateException"。具体而言:

mscorlib.dll 中首次出现"System.IO.FileNotFoundException"类型的异常

附加信息:伪造以加载文件或程序集(原:Неудалосцзагрузирафайлиласборку)"Microsoft.Threading.Tasks.Extensions.Desktop,版本=1.0.16.0,区域性=中性,PublicKeyToken=b03f5f7f11d50a3a"或者依赖关系之一。找不到指定的文件(最初为:

如果存在此异常的处理程序,则程序可以安全地继续运行。

它可能很容易修复,我想我忽略了一些东西,但我不知道它是什么。你能告诉我该怎么做吗,或者我应该在文档中的哪里查找吗?

UPD:我自己修复了:我所要做的就是通过命令"更新Microsoft.Bcl.Async;安装包Microsoft.Bcl.Async-版本1.0.166-beta-Pre"在NuGet中。

';System.AggregateException';尝试使用Google API进行身份验证时,在ms

我看到你自己已经解决了这个问题,但无论如何,你在下面的线程中有更多关于它的文档:ASP.net应用程序崩溃-无法加载文件或程序集';Microsoft.Threading.Tasks.Extensions.Desktop';