0

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

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(); 
    } 
} 
} 

但是,当我试图建立 - 这与“System.AggregateException”崩溃发生在第一mscorlib.dll中(UserCredential凭证= ...)线。具体做法是:

类型 'System.IO.FileNotFoundException' 的第一次机会异常出现在mscorlib.dll

其他信息:Falied到加载文件或程序(原本:Неудалосьзагрузитьфайлилисборку)“ Microsoft.Threading.Tasks.Extensions.Desktop,Version = 1.0.16.0,Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a“或其中一个依赖关系。找不到指定文件(原:。либооднуизихзависимостейНеудаетсянайтиуказанныйфайл)

如果这个异常的处理程序,该程序可以安全地继续。

这可能是一件易于修复的东西,我想我忽略了一些东西,但我不知道它是什么。你能告诉我,该怎么做,或者我应该看什么文档?

UPD:自己修改: 我所要做的只是在NuGet中通过命令“Install-Package Microsoft.Bcl.Async -Version 1.0.166-beta -Pre”更新Microsoft.Bcl.Async。

回答

相关问题