title: 'System.AggregateException' occurred in mscorlib.dll, when trying to authenicate using Google API
body: <p>I'm trying to make a little calendar app, just for myself, using Google Calendar API. I'm using C# and .NET for this. Basically, all I did was copy the example code from <a href="https://developers.google.com/google-apps/calendar/instantiate" rel="nofollow noreferrer">here</a>
  and added FileDataStore class from <a href="https://code.google.com/p/google-api-dotnet-client/source/browse/Src/GoogleApis.DotNet4/Apis/Util/Store/FileDataStore.cs" rel="nofollow noreferrer">here</a>
  Created a project in Google Developers Console, enabled API for the calendar, installed the libraries via NuGet, and all that.
  So my code looks like this now:</p>
  <pre><code>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 = &quot;here's my client id&quot;,
                  ClientSecret = &quot;and the secret&quot;,
              },
              new[] { CalendarService.Scope.Calendar },
              &quot;user&quot;,
              System.Threading.CancellationToken.None).Result;
  
          // Create the service.
          var service = new CalendarService(new BaseClientService.Initializer()
          {
              HttpClientInitializer = credential,
              ApplicationName = &quot;Calendar API Sample&quot;,
          });
          InitializeComponent();
      }
  }
  }
  </code></pre>
  <p>But when I'm trying to build it - it crashes with 'System.AggregateException' occurred in mscorlib.dll on the first(UserCredential credential =...) line. Specifically:</p>
  <blockquote>
  <p>A first chance exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll</p>
  <p>Additional information: Falied to load file or assembly(originally:Не удалось загрузить файл или сборку) &quot;Microsoft.Threading.Tasks.Extensions.Desktop, Version=1.0.16.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a&quot; or one of the dependencies. Couldn't find specified file(originally:либо одну из их зависимостей. Не удается найти указанный файл.)</p>
  <p>If there is a handler for this exception, the program may be safely continued.</p>
  </blockquote>
  <p>It's probably something easy to fix, and I guess I overlooked something, but I have no idea what it is. Can you tell me, what to do, or where in the documentation should I look?</p>
  <p>UPD: Fixed it myself:
  all I had to do was update Microsoft.Bcl.Async via command &quot;Install-Package Microsoft.Bcl.Async -Version 1.0.166-beta -Pre&quot; in NuGet.</p>