• Question

  • Environment: VS 2013 in Win 8.1

    I tried the sample Store app in "Working with the code examples" (really for beginners as I am).

    The code is:

            // Signs the user into their Microsoft account.
            private async void SignIn(object sender, RoutedEventArgs e)
                    LiveAuthClient auth = new LiveAuthClient();
                    LiveLoginResult loginResult = await auth.LoginAsync(new string[] { "wl.basic" });
                    if (loginResult.Status == LiveConnectSessionStatus.Connected)
                        this.infoTextBlock.Text = "Signed in";
                catch (LiveAuthException exception)
                    this.infoTextBlock.Text = "Error signing in: " + exception.Message;

    At the line .. loginResult = await auth.... I get an exception saying:

    "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."

    Note that according to VS-locals the variable 'auth' is NOT null at this point!

    What's wrong?

    Monday, April 13, 2015 8:12 AM

All replies

  • Can you explain on which line the exception is thrown?

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Monday, April 13, 2015 2:32 PM
  • The line

    LiveLoginResult loginResult = await auth.LoginAsync(new string[] { "wl.basic" });

    throws the exception; as if 'auth' was null, however it is not.

    I also tried the similar sample for Windows Phone in the same "Working with the code examples" document; in this case I get the message:

    "Microsoft account is experiencing technical problems. Please try again later."

    Tuesday, April 14, 2015 7:16 AM