在我的WinRT应用程序中,我希望用户连接到他的Hotmail帐户以访问他的联系人。我使用Microsoft的Live Connect SDK中的Hotmail API。调用LoginAsync时出现NullReferenceException
为了建立连接,我使用这个sample代码相同的文档。
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;
}
}
但代码的方法LoginAsync提高一个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
我不认为问题来自authClient,因为在调用LoginAsync时它不为null。根据此post,问题来自未初始化的资源字典。有谁知道这个问题,并最终如何解决它?
感谢
编辑
要在WinRT的应用程序使用Live Contect,你需要声明它在Windows Store Dashboard,也许这就是解决方案,我没有一个Windows Store帐户。
是的,我认为问题来自这里,我还没有商店帐户。 – Max 2013-05-21 14:38:51
这并没有解决我的问题。我仍然在LiveLoginResult上得到一个NullReferenceException – uSeRnAmEhAhAhAhAhA 2014-01-21 08:42:43