【问题标题】:Problems accessing SkyDrive from Windows Phone 7从 Windows Phone 7 访问 SkyDrive 的问题
【发布时间】:2012-01-15 01:52:55
【问题描述】:

我们正在使用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" />

【问题讨论】:

  • 您可以使用 Fiddler 嗅探应用程序流量。

标签: windows-phone-7 onedrive live-connect-sdk


【解决方案1】:

看来我使用的是 Live Connect SDK 5.0 的 Beta 版。一旦我升级到 RTM 版本(并进行了所需的代码更改),它又开始工作了。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-06-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-07-20
    相关资源
    最近更新 更多