Monogame, Xbox One, and the Creator's Program

I think I found the solution for the user creation crash:

https://social.msdn.microsoft.com/Forums/en-US/1c89e4c2-d0d9-4b51-90f9-e45e98a9b325/new-xboxliveuser-weird-exception?forum=xboxlivedev

follow step 4 :

1 Like

Hi Adman1974. Congratulations on your accomplishment
I have added a config file to my game and it no longer crashes. Thank you both

Can you please provide a sample of code that you used to see if the user is signed in, and if not, display the panel so they can choose a user to sign in with

Thanks Adman1974

The status I am getting is UserInteractionRequired

I have noticed I cannot sign into my xboxone sandbox despite adding it as a test account and updating the settings by clicking the Test button

I have emailed Microsoft for ideas, then I will try again

I will keep you posted

Thanks again

1 Like

Why is Adman1974’s post flagged?

OK so I have tried a few different bits of code based on what has been kindly provided on this forum but I still cannot get the sign in to work. I have kept the following code very very simple to demonstrate the point it is breaking down

private async void GetUser()
{
SignInResult signInSilentlyTask;
SignInResult signInLoudlyTask;
user = new XboxLiveUser();
debug = ā€œā€;

        var dispatcher = Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher;
        signInSilentlyTask = await user.SignInSilentlyAsync(null);
        if (signInSilentlyTask.Status == SignInStatus.Success)
        {
            debug += "Worked ";
        }
        else
        {
            debug += signInSilentlyTask.Status.ToString();
        }
        if (signInSilentlyTask.Status == SignInStatus.UserInteractionRequired)
        {
            signInLoudlyTask = await user.SignInAsync(null); // **Error here**
            debug += signInLoudlyTask.Status.ToString();
        }
        debug += " exit";

}

When I try user.SignInAsync(null); or user.SignInAsync(dispatcher); I get an error
System.InvalidOperationException ā€˜Operation is not valid due to the current state of the object’

System.InvalidOperationException occurred
HResult=0x80131509
Message=Operation is not valid due to the current state of the object.
Source=
StackTrace:
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at CatStack.Game1.d__163.MoveNext() in C:\Users\xx\source\repos\CatStack\CatStack\Game1.cs:line 561

I have tried different combinations, null, dispatcher, two dispatcher objects, .CoreApplication.GetCurrentView() instead of .CoreApplication.MainView, try / catch statements. Nothing seems to work. I get the same error message

I am signed into my sandbox with a valid user. I can see my profile when I launch the game and press the XBox home button

But I cannot seem to be able to get the signed in user or force a sign in

Your help will be much appreciated

I think it could be a problem with the code running in a non-UI thread. Could you try this?

signInLoudlyTask = await user.SignInAsync(dispatcher);

1 Like

Hi KakCAT. Thanks for your reply

I had initially tried what you had posted before with no luck but I thought I would try again just to make sure

I discovered there was a subtle difference in the error message I was getting (I’m not sure why it didn’t appear yesterday):
The application requesting authentication tokens is either disabled or incorrectly configured

The solution was to right click the game --> Store --> Associate App with Store

I think the reason why I got this error is because I generated my config file from Unity so it has about 8 lines in it (instead of the 3 you sent to me) - including links to the ids I created. The reason I generated it from unity is because I wanted to look at the backend files while trying to work out how to get the sign in working

I am going to try working with a leaderboard now and then trying to get a game published (it is a simple game). If successful I will document a start to end process (along with mistakes I made along the way) and post it in a blog for use with this forum

Thanks to everyone for your help

Thanks for the followup! This is super confusing stuff, and the Internet Gods smile on those who fix their own problems and post their solutions for others to see!

I don’t want to be all ā€œI told you so!ā€, but just for future coders… there are some hoops you need to jump through before your stuff starts working. And you’ll get weird esoteric errors if your app is not recognized by Microsoft.

Good luck with leaderboards! Please do document and share your problems and solutions!

1 year later I’ve found a proper way to discover the reasons why Xbox live DLL hard crashes without apparent reason.

If you set up your project properties -> Debug to debugger type Mixed (Managed and Native) you get a very descriptive error in the Debug Output when the crash happens. For some reason that message does not appear without native debugging.

So finally I found a bug (only happenning when debugging) of my game randomly crashing: It was a Xbox Live throttling message.

I know it’s an old thread, but it will surely help somebody if he’s running into the hard crashes ( C# coders sure are not used to get those :slight_smile: )

Reviving a VERY old thread… My game (Hidden in Plain Sight) was published to the Xbox marketplace about 8 years ago.

Just recently, it stopped working. Which is to say, users are now reporting an error when starting the game ā€œError signing in to Xbox Liveā€¦ā€

I haven’t changed anything. I sold my Xbox One years ago. Did something change on the back end? Are Xbox Live services no longer available or have they been deprecated or something?

This is the code that is being a called and showing the ā€œError signing in to Xbox Liveā€¦ā€ message box

   private async void GetUser(int index)
    {
        try
        {

            if (Globals.Xboxusers[index] == null)
            {
                Windows.System.UserPicker p = new Windows.System.UserPicker();
                
                var pickedUser = await p.PickSingleUserAsync();
                XboxLiveUser user = new XboxLiveUser(pickedUser);

                SignInStatus signInStatus;
                SignInResult signInSilentlyTask = await user.SignInSilentlyAsync(null);

                signInStatus = signInSilentlyTask.Status;
                if (signInSilentlyTask.Status == SignInStatus.Success)
                {
                    Globals.Xboxusers[index] = user;
                    Globals.GamerTags[index] = user.Gamertag;
                    UserSignedIn = true;
                    UserSigningIn = false;
                }
                else
                if (signInSilentlyTask.Status == SignInStatus.UserCancel)
                {
                    Globals.GamerTags[index] = "Player " + index.ToString();
                    UserSignedIn = false;
                    UserSigningIn = false;
                    MessageBoxScreen m = new MessageBoxScreen("Cancelled signing in to Xbox Live...");
                    ScreenManager.AddScreen(m, ControllingPlayer);
                }
                else
                if (signInSilentlyTask.Status == SignInStatus.UserInteractionRequired)
                {
                    SignInResult signInNotSilentlyTask = await user.SignInAsync(null);
                    if(signInNotSilentlyTask.Status == SignInStatus.Success)
                    {
                        Globals.Xboxusers[index] = user;
                        Globals.GamerTags[index] = user.Gamertag;
                        UserSignedIn = true;
                        UserSigningIn = false;
                    }
                    else
                    {
                        Globals.GamerTags[index] = "Player " + index.ToString();
                        UserSignedIn = false;
                        UserSigningIn = false;
                        MessageBoxScreen m = new MessageBoxScreen("Error signing in to Xbox Live...");
                        ScreenManager.AddScreen(m, ControllingPlayer);
                    }

                }
            }

        }
        catch (System.Exception ex)
        {
            Globals.GamerTags[index] = "Player " + index.ToString();
            UserSignedIn = false;
            UserSigningIn = false;
            MessageBoxScreen m = new MessageBoxScreen("Error signing in to Xbox Live...");
            ScreenManager.AddScreen(m, ControllingPlayer);
        }
    }

Well, it isn’t broken at the very least, but certainly is deprecated since UWP-based builds altogether are deprecated. That said, we had a UWP build on Xbox One until yesterday (actually, still do, because we just submitted the updated GDKX build and it’s still in cert), and ours is still able to sign-in. Tough to say exactly what problem you’re having, or if you’d be able to submit an updated UWP build even if you tried to fix it. The only significant difference I see between your XSAPI use and ours is that we don’t attempt to use the Windows UserPicker first.

There has been some discussion about this on a Microsoft Game Development discord – apparently something recently broke between UWP applications and Xbox Live services. It’s unclear if/when it will get fixed, and it doesn’t sound like it’s very high priority.

I’m happy (and sad) to hear that it’s not only my game, but a whole class of games made for the Creators Program.

But suffice to say, this isn’t a Monogame issue.

1 Like