0

在我的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帐户。

回答

3

您需要向商店注册您的应用程序。从VS转到项目 - >存储 - >关联应用程序与商店

+0

是的,我认为问题来自这里,我还没有商店帐户。 – Max 2013-05-21 14:38:51

+0

这并没有解决我的问题。我仍然在LiveLoginResult上得到一个NullReferenceException – uSeRnAmEhAhAhAhAhA 2014-01-21 08:42:43

0

我有与5.6.2.0相同的问题。

要修复它(作为解决方法),我把Microsoft.Live.pri和Microsoft.Live \ SDKManifest.xml放在Microsoft.Live.dll旁边(从https://github.com/liveservices/LiveSDK-for-Windows)。否则它不能得到错误描述(对于任何错误情况,e.t.没有互联网等)和崩溃。

我已为此问题添加了代码。它看起来像配置问题

相关问题