throwing error while creating UserCredential ;

0

I am getting the error as :

Could not load file or assembly 'System.Core, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes' or one of its dependencies. The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047)

while executing the code for integrating google calendar in my web site using google API v3:

the code is:

     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;
        } 

am referring this link, why am getting this error? what am doing wrong?

i had add these line to the web config file:

  <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
asked on Stack Overflow Dec 24, 2014 by (unknown user) • edited Dec 25, 2014 by (unknown user)

1 Answer

1

One of components of your solution is dependent on System.Core, Version=2.0.5.0. This assembly should be in bin directory of you solution (I don't know is it web, or win or etc) or in the GAC. Most likely you don't have this assembly on your environment.

answered on Stack Overflow Dec 24, 2014 by IAfanasov

User contributions licensed under CC BY-SA 3.0