質問

I am trying to follow a sample on MSDN to read the properties of a folder on onedrive, but I am running into some errors.

Here is the tutorial I am following: http://msdn.microsoft.com/en-us/library/live/hh826522.aspx#reading_albums

The error I get when I run the code says:

"Error 1 'testRun.MainPage' does not contain a definition for 'session' and no extension method 'session' accepting a first argument of type 'testRun.MainPage' could be found (are you missing a using directive or an assembly reference?) C:\Users\me\Desktop\project"

Am I missing something I have to run before I click the button? The only thing that fails is the "this.session" parameter. I am barely learning the LiveSDK so I'm not sure if I'm missing a reference or what. Thanks for any and all help :)

My Code:

private async void Button_logIn_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                LiveConnectClient liveClient = new LiveConnectClient(this.session);
                LiveOperationResult operationResult =
                    await liveClient.GetAsync("path/to/folder");
                dynamic result = operationResult.Result;
                this.Textblock_status.Text = string.Join(" ", "Album name:", result.name, "ID:", result.id);
            }
            catch (LiveConnectException exception)
            {
                this.Textblock_status.Text = "Error getting album info: " + exception.Message;
            }
        }
役に立ちましたか?

解決

The session object is stored in the LiveAuthClient object when the user is logged in: http://msdn.microsoft.com/en-us/library/microsoft.live.liveauthclient.session.aspx

From the error, it looks like session is not a method of the current page, which also makes it inaccessible from this method. You'll want to store the session object somewhere that the methods can access it after the user logs in.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top