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 here and added FileDataStore class from here 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:
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();
}
}
}
But when I'm trying to build it - it crashes with 'System.AggregateException' occurred in mscorlib.dll on the first(UserCredential credential =...) line. Specifically:
A first chance exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll
Additional information: Falied to load file or assembly(originally:Не удалось загрузить файл или сборку) "Microsoft.Threading.Tasks.Extensions.Desktop, Version=1.0.16.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" or one of the dependencies. Couldn't find specified file(originally:либо одну из их зависимостей. Не удается найти указанный файл.)
If there is a handler for this exception, the program may be safely continued.
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?
UPD: Fixed it myself: all I had to do was update Microsoft.Bcl.Async via command "Install-Package Microsoft.Bcl.Async -Version 1.0.166-beta -Pre" in NuGet.
I saw that you already solved it yourself, but anyway you have more documentation on it in the following thread: ASP.net app crashes - Could not load file or assembly 'Microsoft.Threading.Tasks.Extensions.Desktop'