我想使用OAuth2和.Net 4.5框架构建Google BigQuery C#ASP.net应用程序。我跑这些的NuGet安装ASP.net应用程序崩溃 - 无法加载文件或程序集'Microsoft.Threading.Tasks.Extensions.Desktop'
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”:
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"
}
);
}
}
}
我设置特定页面作为项目起始页。我拿起“已安装的应用”当我建立的客户ID文件在谷歌控制台
APIS & auth -> Credentials -> CREATE NEW CLIENT ID
,我确信我添加文件(的client_secrets.json)在VS2013的解决方案资源管理器。在代码隐藏方面,我确信我已正确映射到Server.MapPath的client_secrets文件。对于凭证机构,我使用此代码
<https://code.google.com/p/google-api-dotnet-client/wiki/OAuth2>
作为起点。当我运行的应用程序,它返回一个与
无法加载文件或程序集Microsoft.Threading.Tasks.Extensions.Desktop启动浏览器错误页,版本= 1.0.16.0,文化=中立,公钥= b03f5f7f11d50a3a'或它的一个依赖关系。该系统找不到指定的文件。
并在“凭证=”行崩溃。我试图添加一些实际的ASP.net崩溃的浏览器页面的图像,显示程序集加载跟踪/堆栈跟踪/等,但它看起来像我没有这个帐户权限。当我在“证书=”行设置一个断点,然后通过
DEBUG -> Start Debugging
在VS2013
运行应用程序,网页停止在“证书=”线和一个文件选择器打开,寻找文件
"GoogleClientSecrets.cs"
从目录
“C:\代码\ google.com \谷歌API-DOTNET客户端\ DEFAULT \工具\ Google.Apis.Release \ BIN \调试\输出\ DEFAULT \ SRC \ GoogleApis.Auth \ OAuth2 \ GoogleClientSecrets.cs“
这是无处在驱动器上。在生成的ASP.net错误页面中使用Assembly Load Trace,我尝试了解建议的配置文件,但没有任何工作。更一般地说,我试着在StackOverflow中寻找这个问题,虽然我找到了一些提及它的东西,但没有一个材料有帮助。
你好。对不起,延迟。我试过你的建议,它的工作原理。谢谢你的帮助! - Frank –