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。

回答

相關問題