微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

我想使用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>

为起点。当我运行应用程序,它返回一个浏览器错误页面开头

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.

并在“credential =”行中崩溃。我试图添加一些实际的ASP.net崩溃的浏览器页面的图像显示装配跟踪/堆栈跟踪等,但它看起来像我没有这个帐户的权限。当我在“credential =”行设置断点,然后运行应用程序

DEBUG -> Start Debugging

在VS2013中,页面停在“credential =”行,文件选择器打开,查找文件

"GoogleClientSecrets.cs"

从目录

“c:\code\google.com\google-api-dotnet-client\default\Tools\Google.Apis.Release\bin\Debug\output\default\Src\GoogleApis.Auth\OAuth2\GoogleClientSecrets.cs”

这是无处不在的。在生成的ASP.net错误页面中使用Assembly Load Trace,我尝试通过建议的配置文件挖掘,但没有任何工作。更一般来说,我试图在StackOverflow中寻找这个问题,而当我确实找到了一些提及的时候,没有一个帮助。

解决方法

因为错误是基于Microsoft.Bcl.Async的最新版本在.NET 4.5中不起作用的事实,您可以尝试执行以下操作:

打开您的软件包管理器控制台,并运行以下命令:
1)卸载 – 打包Microsoft.Bcl.Async -Force
2)Install-Package Microsoft.Bcl.Async -Version 1.0.16

它在我目前正在写的一个样本中。请让我知道,如果它适用于你。

更新(3月21日):
您可以更新软件包(新版本1.0.166-beta可用 – https://www.nuget.org/packages/Microsoft.Bcl.Async/1.0.166-beta)。我在VS2013测试它与.NET 4.5框架,它的工作原理。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


这篇文章主要讲解了“WPF如何实现带筛选功能的DataGrid”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“WPF...
本篇内容介绍了“基于WPF如何实现3D画廊动画效果”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这...
Some samples are below for ASP.Net web form controls:(from http://www.visualize.uk.com/resources/asp
问题描述: 对于未定义为 System.String 的列,唯一有效的值是(引发异常)。 For columns not defined as System.String, the only vali
最近用到了CalendarExtender,结果不知道为什么发生了错位,如图在Google和百度上找了很久,中文的文章里面似乎只提到了如何本地化(就是显示中文的月份)以及怎么解决被下拉框挡住的问题,谈
ASP.NET 2.0 page lifecyle ASP.NET 2.0 event sequence changed a lot since 1.1. Here is the order: App
静态声明: &#39; Style=&quot;position: relative&quot; AppendDataBoundItems=&quot;True&quot;&gt; (无 或 空 或
以下内容是从网络上搜集资料,然后整理而来的。不当之处,请不吝指教。(The following were from network, and edited by myself. Thanks in a
Imports System Imports System.Reflection Namespace DotNetNuke &#39;*********************************
Ok so you have all seen them: “8 million tools for web development”, “5 gagillion tools that if you