MVVM Light가 포함 된 Windows 8.1 앱 (XAML/C#)을 개발하고 있습니다.W8.1 Live SDK 5.6 - LiveAuthClient.InitializeAsync System.NullReferenceException
필자는 디버깅을 위해 필자의 LiveId를 코드 안에 보관했지만, 지금은 LogIn을 할 시간입니다.
this.authClient = new LiveAuthClient();
LiveLoginResult loginResult = await this.authClient.InitializeAsync(scopes);
그것은 나에게 오류주고 유지 :
private static readonly string[] scopes =
new string[] {
"wl.signin",
"wl.basic",
"wl.offline_access"};
private LiveAuthClient authClient;
private LiveConnectClient liveClient;
public DashboardView()
{
this.InitializeComponent();
}
protected override void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
this.InitializePage();
}
private async void InitializePage()
{
this.authClient = new LiveAuthClient();
LiveLoginResult loginResult = await this.authClient.InitializeAsync(scopes);
if (loginResult.Status == LiveConnectSessionStatus.Connected)
{
if (this.authClient.CanLogout)
{
this.btnLogin.Content = "Sign Out";
}
else
{
this.btnLogin.Visibility = Visibility.Collapsed;
}
this.liveClient = new LiveConnectClient(loginResult.Session);
this.GetMe();
}
}
private async void btnLogin_Click(object sender, RoutedEventArgs e)
{
if (this.btnLogin.Content.ToString() == "Sign In")
{
LiveLoginResult loginResult = await this.authClient.LoginAsync(scopes);
if (loginResult.Status == LiveConnectSessionStatus.Connected)
{
if (this.authClient.CanLogout)
{
this.btnLogin.Content = "Sign Out";
}
else
{
this.btnLogin.Visibility = Visibility.Collapsed;
}
this.liveClient = new LiveConnectClient(loginResult.Session);
this.GetMe();
}
}
else
{
this.authClient.Logout();
this.btnLogin.Content = "Sign In";
}
}
private async void GetMe()
{
Task<LiveOperationResult> task = this.liveClient.GetAsync("me");
var result = await task;
dynamic profile = result.Result;
}
나는 심지어 일부 시도 : 코드
An exception of type 'System.NullReferenceException' occurred in mscorlib.dll but was not handled in user code
Additional information: Object reference not set to an instance of an object.
소스를
현재 나는이 코드 조각으로 붙어있어 다른 범위와 이것은 나의 마지막 시도이었다.
미리 감사드립니다.
http://stackoverflow.com/questions/4660142/what-is-a-nullreferenceexception-and-how-do-i-fix-it –
@ SonerGönül 좋아, 내가 알고하지만 난 var authClient를 초기화했습니다. 코드에서 초기화되지 않은 변수는 어디에 있습니까? –
LiveConect Auth (SkyDrive 용) NullReferenceException (WTH)? (http://stackoverflow.com/questions/21247297/liveconect-auth-for-skydrive-nullreferenceexception-wth) –