首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >ASP.net应用程序崩溃 - 无法加载文件或程序集“Microsoft.Threading.Tasks.Extensions.Desktop”?

ASP.net应用程序崩溃 - 无法加载文件或程序集“Microsoft.Threading.Tasks.Extensions.Desktop”?

提问于 2018-02-07 05:17:13
回答 2关注 0查看 1.5K

想使用OAuth2和.NET 4.5框架构建一个GoogleBigQueryC#ASP.NET应用程序

代码语言:txt
复制
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

将相关的“usings”放在代码隐藏文件“default.aspx.cs”中:

代码语言:txt
复制
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"
                }
            );
        }
    }
}

将这个特定的页面设置为项目开始页面

代码语言:txt
复制
APIS & auth -> Credentials -> CREATE NEW CLIENT ID

确保正确地映射到客户端。使用Server.MapPath

代码语言:txt
复制
<https://code.google.com/p/google-api-dotnet-client/wiki/OAuth2>
代码语言:txt
复制
DEBUG -> Start Debugging

回答

和开发者交流更多问题细节吧,去 写回答
相关文章

相似问题

相关问答用户
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档