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

When I try user.SignInAsync(null); or user.SignInAsync(dispatcher); I get an errorSystem.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

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

Adman1974:

At some point, you need to associate your code with an actual store app. Which means you need to visit the Microsoft dev site, register your app, and associate your Visual Studio project with the store app.

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 )