我们正在使用Live Connect SDK 5.0从我们的Windows Phone 7.5应用程序中检索SkyDrive中的图片。
下面的应用程序代码(简化)过去几天才开始工作。现在,当我们尝试访问imageStream(或回调中捕获的任何其他信息)时,我们得到 System.Argument 异常(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" />
答案 0 :(得分:0)
似乎我使用的是Live Connect SDK 5.0的Beta版本。一旦我升级到RTM版本(并且需要更改代码),它就会重新开始工作。