title: ASP.net app crashes - Could not load file or assembly 'Microsoft.Threading.Tasks.Extensions.Desktop'
body: <p>I want to build a Google BigQuery C# ASP.net application using OAuth2 and the .Net 4.5 framework. I ran these NuGet installs</p>
  
  <pre><code>Install-Package Google.Apis.Bigquery.v2 -Pre
  Install-Package Google.Apis.Authentication.OAuth2 -Version 1.2.4696.27634
  
  Install-Package Google.Apis -Pre
  Install-Package Google.Apis.Auth -Pre
  </code></pre>
  
  <p>and I placed the relevant "usings" in code-behind file "default.aspx.cs":</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.IO;
  using System.Threading;
  using System.Web;
  using System.Web.UI;
  using System.Web.UI.WebControls;
  
  using Google.Apis.Auth.OAuth2;
  using Google.Apis.Services;
  using Google.Apis.Bigquery.v2;
  using Google.Apis.Bigquery.v2.Data;
  
  namespace BigQueryDemoApp
  {
      public partial class _Default : Page
      {
          protected void Page_Load(object sender, EventArgs e)
          {
              UserCredential credential;
              FileStream stream;
  
              using (stream = new FileStream(
                      Server.MapPath("~/client_secrets.json"),
                      FileMode.Open, FileAccess.Read)
                  )
              {
                  GoogleWebAuthorizationBroker.Folder =
                      "Tasks.Auth.Store";
                  credential = GoogleWebAuthorizationBroker.
                      AuthorizeAsync(
                      GoogleClientSecrets.Load(stream).Secrets,
                      new[] { BigqueryService.Scope.Bigquery },
                      "user", CancellationToken.None).Result;
              }
  
              // Initialize the service.
              var Service = new BigqueryService(
                  new BaseClientService.Initializer()
                  {
                      HttpClientInitializer = credential,
                      ApplicationName = "BigQueryDemo"
                  }
              );
          }
      }
  }
  </code></pre>
  
  <p>I set this specific page as the project start page. I picked "Installed application" when I built the Client ID file at the Google console </p>
  
  <pre><code>APIS &amp; auth -&gt; Credentials -&gt; CREATE NEW CLIENT ID
  </code></pre>
  
  <p>and I made sure I added this file (client_secrets.json) with the solution explorer in VS2013. In the code-behind, I made sure that I correctly mapped to the client_secrets file with Server.MapPath. For the credential machinery, I used this code</p>
  
  <pre><code>&lt;https://code.google.com/p/google-api-dotnet-client/wiki/OAuth2&gt;
  </code></pre>
  
  <p>as the starting point. When I run the app, it returns a browser error page that starts with</p>
  
  <blockquote>
    <p>Could not load file or assembly 'Microsoft.Threading.Tasks.Extensions.Desktop, Version=1.0.16.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.</p>
  </blockquote>
  
  <p>and crashes at the "credential =" line. I tried to add in some images of the actual ASP.net crashed browser page showing the Assembly Load Trace / Stack Trace / etc. but it looks like I don't have the account rights for this. When I set a breakpoint at the "credential =" line and then run the app through</p>
  
  <pre><code>DEBUG -&gt; Start Debugging
  </code></pre>
  
  <p>in VS2013, the page stops at the "credential =" line and a file picker opens, looking for file</p>
  
  <pre><code>"GoogleClientSecrets.cs"
  </code></pre>
  
  <p>from directory</p>
  
  <blockquote>
    <p>"c:\code\google.com\google-api-dotnet-client\default\Tools\Google.Apis.Release\bin\Debug\output\default\Src\GoogleApis.Auth\OAuth2\GoogleClientSecrets.cs"</p>
  </blockquote>
  
  <p>which is nowhere on the drive. Using the Assembly Load Trace in the generated ASP.net error page, I tried digging around through the suggested configuration files but nothing worked. More generally, I tried looking for this issue in StackOverflow and while I did find some mention of it, none of that material helped.</p>