2015-02-23 330 views
0

我希望有人可以幫助我,我試圖創建一個連接到辦公室365以提取聯繫信息的xamarin android應用程序。如果你的谷歌「在你的應用程序中放一些office 365」,並且打開第一個鏈接,我可以找到我正在遵循的教程。作者是Mayur Tendulkar。Xamarin.Android Office 365身份驗證

我能夠將連接的服務添加到我的應用程序和所有程序集下載,儘管可以從教程(ActiveDirectorApiSample,CalendarApiSample等)的步驟4的屏幕截圖中看到的示例cs文件不會被添加到我的項目中:http://i.imgur.com/olLfjoN.png

當試圖添加EnsureClientCreated()方法的Visual Studio警告我說,Authenticator的命名空間找不到,所以我嘗試添加它:
http://i.imgur.com/JSRc3ha.png

我注意到,Visual Studio中嘗試使用Xamarin的補充。 Auth,但是如果我檢查教程中的源代碼我下面的Xamarin.Auth參考是不是有:

using System; 
using Android.App; 
using Android.Content; 
using Android.Runtime; 
using Android.Views; 
using Android.Widget; 
using Android.OS; 
using System.Threading.Tasks; 
using System.Collections.Generic; 
using Microsoft.Office365.Exchange; 
using Microsoft.Office365.OAuth; 
using System.Linq; 

namespace O365Client 
{ 
    [Activity(Label = "O365 Client", MainLauncher = true, Icon = "@drawable/icon")] 
    public class MainActivity : ListActivity 
    { 
     protected override void OnCreate(Bundle bundle) 
     { 
      base.OnCreate(bundle); 
      GetMessages (this); 

     } 
     const string ExchangeResourceId = "https://outlook.office365.com"; 
     const string ExchangeServiceRoot = "https://outlook.office365.com/ews/odata"; 

     public async Task<IEnumerable<IMessage>> GetMessages(Context context) 
     { 
      var client = await EnsureClientCreated(context); 

      var messageResults = await (from i in client.Me.Inbox.Messages 
             orderby i.DateTimeSent descending 
             select i).ExecuteAsync(); 
      MyGlobalDeclaration.Messages = messageResults.CurrentPage.ToList(); 
      ListAdapter = new HomeScreenAdapter(this, MyGlobalDeclaration.Messages); 
      return messageResults.CurrentPage; 
     } 

     private async Task<ExchangeClient> EnsureClientCreated(Context context) 
     { 
      Authenticator authenticator = new Authenticator(context); 
      var authInfo = await authenticator.AuthenticateAsync(ExchangeResourceId); 

      return new ExchangeClient(new Uri(ExchangeServiceRoot), authInfo.GetAccessToken); 
     } 

     protected override void OnListItemClick (ListView l, View v, int position, long id) 
     { 
      var bodyActivity = new Intent (this, typeof(MessageBodyActivity)); 
      bodyActivity.PutExtra ("Id", v.Tag.ToString()); 
      StartActivity (bodyActivity); 
     } 
    } 
} 

如果我使用Xamarin.Auth然後與Visual Studio錯誤:無法創建抽象類或接口的實例「Xamarin.Auth.Authenticator」

任何人都可以確認我如何解決Authenticator錯誤?

回答