2013-12-13 151 views
3

我正在使用Google-Auth Calendar API与MVC4,并且我正面临此错误: “无法找到类型或名称空间名称'IAuthorizationState'(您是否缺少?使用指令或程序集引用一)” 这里是我的命名空间:无法找到类型或名称空间名称'IAuthorizationState'

using System; 
using System.Collections.Generic; 
using System.Data; 
using System.Linq; 
using System.Net; 
using System.Threading.Tasks; 
using System.Web.Mvc; 
using HRBC.Areas.Admin.Models; 
using HRBC.Controllers; 
using HRBC.Models; 
using HRBC.Web; 
using Newtonsoft.Json; 
using Newtonsoft.Json.Linq; 
using System.Web.Script.Serialization; 
using System.Xml; 
using System.Diagnostics; 
using System.Text; 
using DotNetOpenAuth.OAuth2; 
using System.IO; 
//using DotNetOpenAuth.OAuth; 
//using Google.Apis.Plus.v1; 
using Google.Apis.Util; 
using Google.Apis; 
using Google.Apis.Services; 
using Google.Apis.Calendar; 
using Google.Apis.Calendar.v3; 
using Google.Apis.Calendar.v3.Data; 
using Google.Apis.Authentication; 
using Google.Apis.Authentication.OAuth2; 
using Google.Apis.Authentication.OAuth2.DotNetOpenAuth; 
using System.Security.Cryptography; 
using System.Configuration; 

,我使用此代码来调用API和刷新令牌:

private static CalendarService CreateService(string token) 
    { 
     //KeyValuePair<string, string> credentials = Ninject.Web.Common.Get3LOCredentials(); 
     var provider = new NativeApplicationClient(GoogleAuthenticationServer.Description, "CLient ID", "Client Secret"); 
     //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["APIkey"].ToString(), 
      GZipEnabled = false 
     }); 
     return service; 
    } 

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

而且我DONOT知道我我在这里失踪。我已经包括了这一切。请帮帮我。

+0

有时候你必须在项目中添加一个引用,试着用Add引用 –

+0

我已经添加了所有那里的命名空间的引用。 –

回答

2

尝试删除后再次添加引用。如果您使用的是tfs或其他存储库,那么可能存在引用错误。

相关问题