调用LoginAsync时出现NullReferenceException

调用LoginAsync时出现NullReferenceException,login,nullreferenceexception,hotmail,winrt-async,live-connect-sdk,Login,Nullreferenceexception,Hotmail,Winrt Async,Live Connect Sdk,在我的WinRT应用程序中,我希望用户连接到他的Hotmail帐户以访问他的联系人。我使用来自Microsoft的 为了建立连接,我使用了相同文档的这组代码 if (!Windows.ApplicationModel.DesignMode.DesignModeEnabled) { authClient = new LiveAuthClient(); LiveLoginResult authResult = await authClient.LoginAsync(n

在我的WinRT应用程序中,我希望用户连接到他的Hotmail帐户以访问他的联系人。我使用来自Microsoft的

为了建立连接,我使用了相同文档的这组代码

if (!Windows.ApplicationModel.DesignMode.DesignModeEnabled)
{
    authClient = new LiveAuthClient();
    LiveLoginResult authResult =
        await authClient.LoginAsync(new string[] { "wl.signin", "wl.basic", "wl.emails" });
    if (authResult.Status == LiveConnectSessionStatus.Connected)
    {
        this.session = authResult.Session;
    }
}
但是代码在方法中引发了NullReferenceException。以下是堆栈跟踪:

   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 Project.View.TestHotmailConnection.<Button_Click_1>d__0.MoveNext() in TestHotmailConnection.xaml.cs:line 63
位于Microsoft.Live.ResourceHelper.GetString(字符串名称)
在Microsoft.Live.TailoredAuthClient.,问题来自未初始化的资源字典。有人知道这个问题吗?最终如何解决

谢谢

编辑


要在WinRT应用程序中使用Live Contect,您需要在中声明它,可能是解决方案,我没有Windows应用商店帐户。

您需要向应用商店注册应用程序。从VS go to Project->Store->将应用程序与商店关联

您需要向商店注册应用程序。从VS go to Project->Store->Associate App and the Store

我对5.6.2.0也有同样的问题

为了修复它(作为解决方法),我将Microsoft.Live.pri和Microsoft.Live\SDKManifest.xml放在Microsoft.Live.dll旁边(从)。否则,它无法获得错误描述(对于任何错误情况,例如,没有互联网等)并崩溃


我已经为这个问题添加了一个代码。看起来是配置问题

我对5.6.2.0也有同样的问题

为了修复它(作为解决方法),我将Microsoft.Live.pri和Microsoft.Live\SDKManifest.xml放在Microsoft.Live.dll旁边(从)。否则,它无法获得错误描述(对于任何错误情况,例如,没有互联网等)并崩溃


我已经为这个问题添加了一个代码。看起来是配置问题

是的,我认为问题来自这里,我还没有商店帐户。这并没有解决我的问题。我仍然在LiveLoginResult上收到一个NullReferenceException是的,我认为问题来自这里,我还没有商店帐户。这并没有解决我的问题。我仍然在LiveLoginResult上收到一个NullReferenceException