未能从程序集加载类型“Google.Apis.Requests.IErrorResponseHandler'Google.Apis” [英] Could not load type 'Google.Apis.Requests.IErrorResponseHandler' from assembly 'Google.Apis'

查看:128
本文介绍了未能从程序集加载类型“Google.Apis.Requests.IErrorResponseHandler'Google.Apis”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在谷歌的.NET API验证日历。我已复制此链接中的code:<一href=\"http://stackoverflow.com/questions/18715909/refresh-token-expiration-time-google-calendar\">Refresh令牌到期时间谷歌日历
未能从程序集加载类型Google.Apis.Requests.IErrorResponseHandler'Google.Apis,版本= 1.6.0.16897,文化=中立,公钥=空

下面是我的code:

 私人CalendarService的CreateService(字符串标记)
    {
        // KeyValuePair&LT;字符串,字符串&GT;凭据= Ninject.Web.Common.Get3LOCredentials();
        VAR提供商=新NativeApplicationClient(GoogleAuthenticationServer.Description,this.clientID,this.ClientSecret);
        //provider.ClientIdentifier = clientID的;
        //provider.ClientSecret = clientSecret;
        变种AUTH =新Google.Apis.Authentication.OAuth2.OAuth2Authenticator&所述; NativeApplicationClient&GT;(提供商(P)=&GT; GetAuthorization(提供商,令牌));
        CalendarService服务=新CalendarService(新BaseClientService.Initializer()
        {
            身份验证= AUTH,
            ApiKey = ConfigurationManager.AppSettings [this.APIkey]的ToString(),
            GZipEnabled = FALSE
        });
        退换货服务;
    }    私有静态IAuthorizationState GetAuthorization(NativeApplicationClient阿根廷,字符串Refreshtoken)
    {
        IAuthorizationState状态=新AuthorizationState(新[] {CalendarService.Scopes.Calendar.GetStringValue()});
        state.Callback =新的URI(NativeApplicationClient.OutOfBandCallbackUrl);
        state.RefreshToken = Refreshtoken;
        返回状态;
    }


解决方案

我卸载并重新安装的NuGet包google.apis.auth解决了这个问题。这是因为安装了多个版本。


  1. 右键单击项目的参考菜单上。手动删除
    所有相关包引用google.apis.auth。


  2. 然后,选择管理的NuGet包,搜索google.apis.auth
    并卸载google.apis.auth。


  3. 重新安装相同的包。


  4. 清洁和重建


如果它不工作,你可以尝试重新安装google.apis吧。

I am Google Auth api Calendar in .net. I have copied the code from this link:Refresh Token Expiration time Google calendar Could not load type 'Google.Apis.Requests.IErrorResponseHandler' from assembly 'Google.Apis, Version=1.6.0.16897, Culture=neutral, PublicKeyToken=null'

Here is my code:

private CalendarService CreateService(string token)
    {
        //KeyValuePair<string, string> credentials = Ninject.Web.Common.Get3LOCredentials();
        var provider = new NativeApplicationClient(GoogleAuthenticationServer.Description, this.clientID, this.ClientSecret);
        //provider.ClientIdentifier = clientID;
        //provider.ClientSecret = clientSecret;
        var auth = new Google.Apis.Authentication.OAuth2.OAuth2Authenticator<NativeApplicationClient>(provider, (p) => GetAuthorization(provider, token));
        CalendarService service = new CalendarService(new BaseClientService.Initializer()
        {
            Authenticator = auth,
            ApiKey = ConfigurationManager.AppSettings[this.APIkey].ToString(),
            GZipEnabled = false
        });
        return service;
    }

    private static IAuthorizationState GetAuthorization(NativeApplicationClient arg, String Refreshtoken)
    {
        IAuthorizationState state = new AuthorizationState(new[] { CalendarService.Scopes.Calendar.GetStringValue() });
        state.Callback = new Uri(NativeApplicationClient.OutOfBandCallbackUrl);
        state.RefreshToken = Refreshtoken;
        return state;
    }

解决方案

I solved this problem by uninstalling and re-installing the NuGet package "google.apis.auth". This was because multiple versions are installed.

  1. Right click on the "References" menu of the project. Manually remove all package references related to google.apis.auth.

  2. Then, select "Manage NuGet Package", search for "google.apis.auth", and uninstall "google.apis.auth".

  3. Reinstall the same package.

  4. Clean and rebuild

If it doesn't work, you might try reinstall "google.apis" as well.

这篇关于未能从程序集加载类型“Google.Apis.Requests.IErrorResponseHandler'Google.Apis”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆