(C#)Azure-实时身份验证期间出现空引用异常

(C#)Azure-实时身份验证期间出现空引用异常,c#,authentication,microsoft-metro,windows-store-apps,azure-mobile-services,C#,Authentication,Microsoft Metro,Windows Store Apps,Azure Mobile Services,我遵循了Azure移动服务页面上的实时身份验证教程() 当我运行这行代码时 LiveLoginResult result = await liveIDClient.LoginAsync(new[] { "wl.basic" }); 无论我做什么,我都会得到一个“NullReferenceException”。我试着把“wl.basic”改成“wl.sign”,但也没用 我已登录到我的Microsoft帐户,我获得允许其登录的弹出窗口,该应用程序与我的开发人员帐户关联,并且我已将客户端密钥和密码

我遵循了Azure移动服务页面上的实时身份验证教程()

当我运行这行代码时

LiveLoginResult result = await liveIDClient.LoginAsync(new[] { "wl.basic" });
无论我做什么,我都会得到一个“NullReferenceException”。我试着把“wl.basic”改成“wl.sign”,但也没用

我已登录到我的Microsoft帐户,我获得允许其登录的弹出窗口,该应用程序与我的开发人员帐户关联,并且我已将客户端密钥和密码添加到我的azure帐户。 非常感谢大家的帮助!这快把我逼疯了。如果有帮助,下面是完整的代码。它没有通过上面提到的行,我也在MSDN上发布了,只是觉得StackOverflow会更有帮助

 private LiveConnectSession session;


    private async System.Threading.Tasks.Task Authenticate()
    { 
     LiveAuthClient liveIDClient = new LiveAuthClient("https://mobileserviceexample.azure-mobile.net/");

        while (session == null)
        {

            // TODO: Added for testing of multiple microsoft accounts. Only works on non-connected accounts
            if (liveIDClient.CanLogout)
            { liveIDClient.Logout(); }

            LiveLoginResult result = await liveIDClient.LoginAsync(new[] { "wl.basic" });
            if (result.Status == LiveConnectSessionStatus.Connected)
            {}
例外情况:

System.NullReferenceException was unhandled by user code
HResult=-2147467261
Message=Object reference not set to an instance of an object.
Source=Microsoft.Live
StackTrace:
   at Microsoft.Live.ResourceHelper.GetString(String name)
   at Microsoft.Live.TailoredAuthClient.<AuthenticateAsync>d__0.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 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 CommunistTutsApp.HomePage.<Authenticate>d__0.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.GetResult()
   at CommunistTutsApp.HomePage.<OnNavigatedTo>d__f.MoveNext()
System.NullReferenceException未由用户代码处理
HResult=-2147467261
Message=对象引用未设置为对象的实例。
Source=Microsoft.Live
堆栈跟踪:
位于Microsoft.Live.ResourceHelper.GetString(字符串名称)
在Microsoft.Live.TailoredAuthClient.d_u0.MoveNext()上
---来自引发异常的上一个位置的堆栈结束跟踪---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务)
在System.Runtime.CompilerServices.TaskWaiter.HandleNonSuccessAndDebuggerNotification(任务任务)中
在System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()中
在Microsoft.Live.LiveAuthClient.d_u4.MoveNext()上
---来自引发异常的上一个位置的堆栈结束跟踪---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务)
在System.Runtime.CompilerServices.TaskWaiter.HandleNonSuccessAndDebuggerNotification(任务任务)中
在System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()中
在cpartutsapp.HomePage.d_u0.MoveNext()上
---来自引发异常的上一个位置的堆栈结束跟踪---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务)
在System.Runtime.CompilerServices.TaskWaiter.HandleNonSuccessAndDebuggerNotification(任务任务)中
在System.Runtime.CompilerServices.TaskAwaiter.GetResult()中
在cpartutsapp.HomePage.d_uf.MoveNext()上
调用LoginAsync时,我遇到了同样的问题——“对象引用未设置为对象的实例”。 确保已在Live Connect设置中输入重定向URL-请参阅所附链接的步骤4-


谢谢大家!

你能发布你得到的全部异常(包括堆栈跟踪)吗?这将有助于查明错误所在的位置。我之所以出现错误,是因为我没有填写Microsoft帐户开发人员中心中的“目标域”字段。