Question

We are using the Live Connect SDK 5.0 to retrieve pictures from SkyDrive from our Windows Phone 7.5 application.

The application code (simplified) below used to work until a few days ago. Now when we try to access the imageStream (or any other information captured in a callback) we get a System.Argument exception (HResult = -2147024809, "Value does not fall within the expected range", but as usual the offending value is not mentioned). We checked our code base and there were no code changes in this area of the product recently.

Were there any API changes? Is there a way (Fiddler, but for applications not IE) to inspect the network traffic in the hope that more information is transmitted from the server? Are there any local values that are being cached that might interfere?

Here's the relevant code:

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);
        }
    }
}

And the SignInButton is defined as follows:

        <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" />
Was it helpful?

Solution

It appears that I was using the Beta version of the Live Connect SDK 5.0. Once I upgraded to the RTM version (and made the code changes required) it started working again.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top