在我的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