【问题标题】:throwing error while creating UserCredential ;创建 UserCredential 时抛出错误;
【发布时间】:2014-12-25 12:36:40
【问题描述】:

我得到的错误是:

无法加载文件或程序集'System.Core,版本=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes' 或 它的依赖项之一。给定的程序集名称或代码库是 无效的。 (HRESULT 异常:0x80131047)

在使用 google API v3 执行在我的网站中集成 google 日历的代码时:

代码是:

     public bool connectCalendar()
        {
            ClientSecrets secrets = new ClientSecrets
            {
                ClientId = "10xxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxxx82.apps.googleusercontent.com",
                ClientSecret = "LxxxxxxxxxxxXYEb3Iaxo3C"
            };
            CalendarService calendarConnection;                try
            {
                UserCredential credential = GoogleWebAuthorizationBroker.AuthorizeAsync(secrets, new string[]{
                    CalendarService.Scope.Calendar}, "user",
                    CancellationToken.None, new FileDataStore("Books.ListMyLibrary")).Result;
//exception is thrown in this line
                var initializer = new BaseClientService.Initializer();
                initializer.HttpClientInitializer = credential;
                initializer.ApplicationName = "secret-heaven-798";
                calendarConnection = new CalendarService(initializer);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                return false;
            }
            return true;
        } 

我指的是这个link,为什么会出现这个错误?做错了什么?

我已将这些行添加到网络配置文件中:

  <dependentAssembly>
    <assemblyIdentity name="System.Core" PublicKeyToken="7cec85d7bea7798e" culture="neutral"/>
    <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
  </dependentAssembly>

【问题讨论】:

标签: c# asp.net .net google-api


【解决方案1】:

您的解决方案的一个组件依赖于 System.Core,版本=2.0.5.0。这个程序集应该在你的解决方案的 bin 目录中(我不知道它是 web 还是 win 等)或GAC。您的环境中很可能没有此程序集。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-01-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-02-16
    • 2021-10-09
    相关资源
    最近更新 更多