我们正在使用Live Connect SDK 5.0从我们的 Windows Phone 7.5 应用程序的 SkyDrive 中检索图片。
下面的应用程序代码(简化)直到几天前都可以正常工作。现在,当我们尝试访问 imageStream(或回调中捕获的任何其他信息)时,我们得到一个System.Argument异常 (HResult = -2147024809, "Value does not fall in the expected range",但像往常一样,有问题的值不是提及)。我们检查了我们的代码库,最近在产品的这方面没有代码更改。
是否有任何 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" />