2014-10-20 131 views
0

我試圖使用https://code.msdn.microsoft.com/Office-365-APIs-Windows-8-63a74ba2上提供的客戶端庫運行Windows 8應用程序示例,但出現以下錯誤。Office 365 API:使用客戶端庫的Windows 8應用程序

「值不能爲空參數名:serviceContext」

私人異步任務EnsureClientCreated(){

 var authenticator = new Authenticator(); 
     var result = await authenticator.AuthenticateAsync("MyFiles", ServiceIdentifierKind.Capability); 

     // Create a client proxy: 
     this.client = new SharePointClient(result.ServiceUri, result.GetAccessToken); 
     this.client.Context.IgnoreMissingProperties = true; 
    } 

    /// <summary> 
    /// Populates the page with content passed during navigation. Any saved state is also 
    /// provided when recreating a page from a prior session. 
    /// </summary> 
    /// <param name="sender"> 
    /// The source of the event; typically <see cref="NavigationHelper"/> 
    /// </param> 
    /// <param name="e">Event data that provides both the navigation parameter passed to 
    /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested and 
    /// a dictionary of state preserved by this page during an earlier 
    /// session. The state will be null the first time a page is visited.</param> 
    private async void navigationHelper_LoadState(object sender, LoadStateEventArgs e) 
    { 
     Exception exception = null; 

     try 
     { 
      this.DefaultViewModel["Items"] = new[] { new { Primary = "Loading...", Secondary = "Please wait..." } }; 

      IOrderedEnumerable<IFileSystemItem> files = await GetOneDriveFiles(); 

      if (files == null) 
      { 
       this.DefaultViewModel["Items"] = null; 
      } 
      else 
      { 
       this.DefaultViewModel["Items"] = files.Select(file => new 
       { 
        Primary = file.Name, 
        Secondary = "Last modified on " + ToLocalTimeString(file.TimeLastModified) 
       }); 
      } 
     } 
     catch (Exception ex) 
     { 
      exception = ex; 
     } 

     if (exception != null) 
     { 
      await ShowErrorMessageAsync(exception.Message); 
     } 
    } 

    private async Task<IOrderedEnumerable<IFileSystemItem>> GetOneDriveFiles() 
    { 
     await EnsureClientCreated(); 

     // Obtain data: 
     var filesRequest = await this.client.Files["Shared with Everyone"].ToFolder().Children.ExecuteAsync(); 
     var files = filesRequest.CurrentPage.OrderBy(e => e.Name); 
     return files; 
    } 

什麼想法?

回答

0

您可以嘗試使用可在此處找到的當前工具版本:http://aka.ms/office365apitoolspreview 如果這樣不能解決問題,那麼查看引起問題的特定API調用的HTTP跟蹤會很有幫助。

+0

我跟着你的鏈接,並連接到在線共享點。但仍然有這個錯誤。 – Thilo 2014-10-21 03:04:50