2012-09-25 62 views
1

我試圖在我的應用中實施Google Drive的使用,但我似乎得到以下錯誤"Method 'get_Error' in type 'Google.Apis.Drive.v2.Data.FileList' from assembly 'Google.Apis.Drive.v2, Version=1.2.4647.29713, Culture=neutral, PublicKeyToken=null' does not have an implementation"。有誰知道爲什麼會發生這種情況?我將我的代碼基於Google爲其任務API提供的示例。下面Google Drive「get_error not implemented」錯誤

代碼:

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Web; 
using System.Web.UI; 
using System.Web.UI.WebControls; 
using System.Web.Util; 
using System.Diagnostics; 
using DotNetOpenAuth.Messaging; 
using DotNetOpenAuth.OAuth2; 
using Google.Apis.Authentication; 
using Google.Apis.Authentication.OAuth2; 
using Google.Apis.Authentication.OAuth2.DotNetOpenAuth; 
using Google.Apis.Util; 
using PrepHub.PrepHub; 
using System.Web.Services; 
using System.Threading; 
using Google.Apis; 
using Google.Apis.Drive.v2.Data; 
using Google.Apis.Drive.v2; 
using Google.Apis.Drive; 


namespace DriveExample 
{ 
    public partial class GDrive : System.Web.UI.Page 
    { 
     private static DriveService _service; // We don't need individual service instances for each client. 
     private OAuth2Authenticator<WebServerClient> _authenticator; 
     private IAuthorizationState _state; 

     private IAuthorizationState AuthState 
     { 
      get 
      { 
       return _state ?? HttpContext.Current.Session["AUTH_STATE"] as IAuthorizationState; 
      } 
     } 

     protected void Page_Load(object sender, EventArgs e) 
     { 

      if (_service == null) 
      { 
       _service = new DriveService(_authenticator = CreateAuthenticator()); 
      } 


      if (HttpContext.Current.Request["code"] != null) 
      { 
       _authenticator = CreateAuthenticator(); 
       _authenticator.LoadAccessToken(); 
      } 

      var ni = _service.Files.List().Fetch(); 

     } 


     private OAuth2Authenticator<WebServerClient> CreateAuthenticator() 
     { 

      var provider = new WebServerClient(GoogleAuthenticationServer.Description); 
      provider.ClientIdentifier = ClientCredentials.ClientID; 
      provider.ClientSecret = ClientCredentials.ClientSecret; 
      var authenticator = 
       new OAuth2Authenticator<WebServerClient>(provider, GetAuthorization) { NoCaching = true }; 
      return authenticator; 
     } 

     private IAuthorizationState GetAuthorization(WebServerClient client) 
     { 
      // If this user is already authenticated, then just return the auth state. 
      IAuthorizationState state = AuthState; 
      if (state != null) 
      { 
       return state; 
      } 
      // Check if an authorization request already is in progress. 
      state = client.ProcessUserAuthorization(new HttpRequestInfo(HttpContext.Current.Request)); 
      if (state != null && (!string.IsNullOrEmpty(state.AccessToken) || !string.IsNullOrEmpty(state.RefreshToken))) 
      { 
       // Store and return the credentials. 
       HttpContext.Current.Session["AUTH_STATE"] = _state = state; 
       return state; 
      } 

      string scope = DriveService.Scopes.Drive.GetStringValue(); 
      OutgoingWebResponse response = client.PrepareRequestUserAuthorization(new[] { scope }); 
      response.Send(); 
      return null; 
     } 

    } 
} 

回答

0

我猜你的一些組件已經過時了。例如,當你有一個程序集時,會出現這個錯誤,可以說foo.dll(v1),並且該程序集正在被bar.dll(v2)引用。 bar.dll中的一個類正在等待Foo中的某個類出現並且不在其中。在你的情況下,它的類訪問器獲取類Error。仔細檢查所有組件,確保它們都是最新版本。

+2

我對使用「Google.Apis.Calendar.v3」的問題完全相同。 api ....我抓住了api(日曆)的源文件,並發現谷歌沒有「實現接口成員'Google.Apis.Requests.IDirectResponseSchema.Error'」在他們的API中的11個地方。所以我繼續並實施它。整理出來的東西。以後再試一下驅動器。但日曆似乎現在工作。感謝您的迴應!乾杯。 – Mulaiko