Click here to Skip to main content
15,896,278 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am working in Live SDK 5.6 and Visual Studio 2013.

How do I assign a "using" directive for "async"?

C#
using Microsoft.Live;
using ???.async;
namespace OneDriveSignin
{
    public partial class _Default : Page
    {
        protected void Button1_Click(object sender, EventArgs e)
        {
            Loginvalue();
        }
        private async void Loginvalue()
        {
            LiveAuthClient authClient = new LiveAuthClient("http://localhost/myapp");
            LiveLoginResult loginResult = await authClient.InitializeAsync(new List<string>() { "wl-signin" });
            this.TextBox1.Text = loginResult.Session.AuthenticationToken;
        }
    }
}

Error code:
XML
An exception of type 'System.InvalidOperationException' occurred in System.Web.dll but was not handled in user code

Additional information: An asynchronous operation cannot be started at this time. Asynchronous operations may only be started within an asynchronous handler or module or during certain events in the Page lifecycle. If this exception occurred while executing a Page, ensure that the Page is marked <%@ Page Async="true" %>. This exception may also indicate an attempt to call an "async void" method, which is generally unsupported within ASP.NET request processing. Instead, the asynchronous method should return a Task, and the caller should await it.
Posted
Updated 25-Apr-15 2:17am
v4
Comments
Sergey Alexandrovich Kryukov 25-Apr-15 21:00pm    
The question makes no sense. What would it supposed to mean, "assign a directive" to anything?
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900