ASP.net应用程序崩溃 – 无法加载文件或程序集“Microsoft.Threading.Tasks.Extensi
|
我想使用OAuth2和.Net 4.5框架构建一个Google BigQuery C#ASP.net应用程序。我运行了这些NuGet安装 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 并将相关的“uses”放在代码隐藏文件“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"
}
);
}
}
}
我将此特定页面设置为项目起始页。当我在Google控制台中建立客户端ID文件时,我选择了“已安装的应用程序” APIS & auth -> Credentials -> CREATE NEW CLIENT ID 我确定我在VS2013中将该文件(client_secrets.json)添加到了解决方案资源管理器中。在代码隐藏中,我确保我使用Server.MapPath映射到client_secrets文件。对于凭证机器,我使用这个代码 <https://code.google.com/p/google-api-dotnet-client/wiki/OAuth2> 为起点。当我运行应用程序,它返回一个浏览器错误页面开头
并在“credential =”行中崩溃。我试图添加一些实际的ASP.net崩溃的浏览器页面的图像显示装配跟踪/堆栈跟踪等,但它看起来像我没有这个帐户的权限。当我在“credential =”行设置断点,然后运行应用程序 DEBUG -> Start Debugging 在VS2013中,页面停在“credential =”行,文件选择器打开,查找文件 "GoogleClientSecrets.cs" 从目录
这是无处不在的。在生成的ASP.net错误页面中使用Assembly Load Trace,我尝试通过建议的配置文件挖掘,但没有任何工作。更一般来说,我试图在StackOverflow中寻找这个问题,而当我确实找到了一些提及的时候,没有一个帮助。 解决方法因为错误是基于Microsoft.Bcl.Async的最新版本在.NET 4.5中不起作用的事实,您可以尝试执行以下操作:打开您的软件包管理器控制台,并运行以下命令: 它在我目前正在写的一个样本中。请让我知道,如果它适用于你。 更新(3月21日): (编辑:安卓应用网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
- 将mvc 5应用程序连接到Azure中的ACS?
- asp.net-mvc – 从MVC Controller调用Web API来构建并传递模
- 决定Umbraco和Orchard之间ASP.NET CMS
- 在ASP.NET Web API的JSON输出中没有时间的日期
- asp.net-mvc-3 – MVC3非顺序索引和DefaultModelBinder
- asp.net-web-api – 角色提供者/成员?如何在asp.net web a
- asp.net-mvc – 在MVC 3中写入只读会话
- asp.net-mvc – 使用OWIN的Google身份验证Oauth在MVC5中没有
- ASP.Net发布超时
- asp.net-mvc – 如何将数据从AuthorizeAttribute传递给Cont
- asp.net-mvc-3 – Html.RenderPartial和Ajax.Beg
- asp.net-mvc – ASP MVC3在actionlink中插入html
- asp.net-mvc – ASP.NET MVC 3用户验证
- asp.net – 使用ASPNet_Regiis加密自定义配置部分
- asp.net – 冻结标题,滚动GridView
- asp.net – 错误:“配置部分’system.webServer
- 在.NET框架中强制使用英语异常
- asp-classic – 与SQL Server Compact Edition 4
- iis – 加速asp.net开发服务器
- asp.net-mvc – 在ASP.NET MVC ViewModel类中获取
