2012-01-13 150 views
0

我們正在使用Live Connect SDK 5.0從我們的Windows Phone 7.5應用程序中檢索SkyDrive中的圖片。從Windows Phone 7訪問SkyDrive的問題

以下的應用程序代碼(簡體)用於工作到幾天前。現在,當我們嘗試訪問imageStream(或回調中捕獲的任何其他信息)時,我們得到一個異常(HResult = -2147024809,「價值不在預期範圍內」,但像往常一樣沒有提到違規價值)。我們檢查了我們的代碼庫,最近在產品的這個區域沒有代碼改變。

是否有任何API更改?有沒有辦法(Fiddler,但對於不是IE的應用程序)檢查網絡流量,希望從服務器傳輸更多信息?是否存在可能會受到干擾的本地值?

下面是相關代碼:

public partial class OptionsPage : PhoneApplicationPage 
{ 
    private LiveConnectClient _liveClient = null; 

    public OptionsPage() 
    { 
     InitializeComponent(); 
    } 

    private void OnSessionChanged(Object sender, LiveConnectSessionChangedEventArgs args) 
    { 
     if (args != null && args.Session != null && args.Session.Status == LiveConnectSessionStatus.Connected) 
     { 
      this._liveClient = new LiveConnectClient(args.Session); 
     this.GetUserPicture(); 
     } 
    } 

    private void GetUserPicture() 
    { 
     var memoryStream = new MemoryStream(); 
     _liveClient.DownloadCompleted += new EventHandler<LiveOperationCompletedEventArgs>(this.GetUserPictureCallback); 
     _liveClient.DownloadAsync("/me/picture?return_ssl_resources=true", memoryStream, memoryStream); 
    } 

    private void GetUserPictureCallback(object sender, LiveOperationCompletedEventArgs e) 
    { 
     _liveClient.DownloadCompleted -= this.GetUserPictureCallback; 

     try 
     { 
      if (e.Error == null) 
      { 
       MemoryStream imageStream = e.UserState as MemoryStream; 
       BitmapImage b = new BitmapImage(); 
       b.SetSource(imageStream); 
      } 
      else 
      { 
       MessageBox.Show(e.Error.Message, "Windows Live Error", MessageBoxButton.OK); 
      } 

     } 
     catch (Exception ex) 
     { 
      MessageBox.Show(ex.Message, "SkyDrive Exception", MessageBoxButton.OK); 
     } 
    } 
} 

而且SignInButton定義如下:

 <live:SignInButton Content="Button" Height="65" HorizontalAlignment="Left" Margin="110,41,0,0" 
      Name="signInButton1" VerticalAlignment="Top" Width="215" ClientId="[REAL_CLIENT_ID]" 
      Scopes="wl.offline_access wl.signin wl.basic wl.skydrive wl.skydrive_update" 
      RedirectUri="https://oauth.live.com/desktop" 
      Branding="Skydrive" 
      TextType="SignIn" 
      Background="Red" 
      SessionChanged="OnSessionChanged" /> 
+1

您可以使用Fiddler嗅探應用程序流量。 – EricLaw 2012-01-13 22:11:58

回答

0

看來,我用的是實時連接SDK 5.0 Beta版。一旦我升級到RTM版本(並且需要更改代碼),它又開始工作了。