1

我正在尝试编写一个简单的 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>

有谁知道这个问题?

4

0 回答 0