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