Method not found: 'Void Google.Apis.Util.Store.FileDataStore..ctor(System.String)'

此生再无相见时 提交于 2019-12-05 11:48:41

Looks like there is a bug in v1.8.2 of Google APIs Client Library. Try using v1.8.1 using nuget with .NET framework 4.

It's really weird. All our samples are using the new library (1.8.2), and they work. Maybe it is related to VS2010, or not installing one of the latest .NET 4 patches? (Make sure .NET Framework 4.0 update KB2468871 (http://www.microsoft.com/en-us/download/details.aspx?id=3556) is installed.

The fact that samples run successfully implies that our environment is different. I'm using VS 2012 on Windows 8. What do you use?

Feel free to open a new issue in our issue tracker (https://code.google.com/p/google-api-dotnet-client/issues/list), and we can take it from there.

Rimon Erez

This is what I've done to resolve the issue :

public UserCredential GetRefreshToken(string refreshToken, string clientID, string clientSecret, string[] scopes)
{
    TokenResponse token = new TokenResponse
    {
        RefreshToken = refreshToken
    };

    IAuthorizationCodeFlow flow = new AuthorizationCodeFlow(new AuthorizationCodeFlow.Initializer(Google.Apis.Auth.OAuth2.GoogleAuthConsts.AuthorizationUrl, Google.Apis.Auth.OAuth2.GoogleAuthConsts.TokenUrl)
    {
        ClientSecrets = new ClientSecrets
        {
            ClientId = clientID,
            ClientSecret = clientSecret
        },
        Scopes = scopes
    });

    UserCredential credential = new UserCredential(flow, "me", token);
    try
    {
        bool success = credential.RefreshTokenAsync(CancellationToken.None).Result;
    }
    catch
    {
        throw;
    }
    return credential;
}

Had the same problem using Visual Studio 2013 + Update 3 on win 8.1 .NET 4.5 was set as the Target Framework of my Console Project (this is selected by default). The issue was fixed by removing every reference to the google apis. Then switching the Target Framework to ".NET Framework 4" (Select project from solution explorer, right click -> Properties -> Application Page -> Target Framework dropdown) Then installing apis with nuget in the following order:

PM> Install-Package Google.Apis
PM> Install-Package Google.Apis.Auth
PM> Install-Package Google.Apis.Drive.v2
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!