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.沒有互聯網等)和崩潰。

我已爲此問題添加了代碼。它看起來像配置問題

相關問題