运行LiveAuthClient的LoginAsync时出错

时间:2013-07-31 19:11:24

标签: c# windows

我正在尝试编写一个简单的Windows应用商店应用,强制用户立即登录。我正在关注这些指南:

http://msdn.microsoft.com/en-us/library/live/hh968445.aspx

并且

http://msdn.microsoft.com/en-us/library/live/hh826543.aspx#csharp

我添加了以下内容:

public LiveConnectSession Session
{
    get
    {
        return _session;
    }
    set
    {
        _session = value;
    }
}

private async void InitAuth()
{
    if (!Windows.ApplicationModel.DesignMode.DesignModeEnabled)
    {
        try
        {
            authClient = new LiveAuthClient();

            List<string> perms = new List<string>() { "wl.signin", "wl.basic", "wl.skydrive" };
            LiveLoginResult authResult = await authClient.LoginAsync(perms);

            if (authResult.Status == LiveConnectSessionStatus.Connected)
            {
                this.Session = authResult.Session;
            }
        }
        catch (Exception e)
        {
            String message = e.Message;
        }
    }
}

我从InitAuth()构造函数中调用App()

我得到一个“未找到元素”异常,以及以下堆栈跟踪:

   at Microsoft.Live.LiveAuthClient.<ExecuteAuthTaskAsync>d__4.MoveNext()
    End of stack trace from previous location where exception was thrown 
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at TuneHoc.App.<InitAuth>d__1.MoveNext() in <filename>

有谁知道这个问题?

0 个答案:

没有答案