1

I'm trying to log in using Live SDK on WP8. I was able to login a few days but now without making any changes to the code I'm getting a first chance exception.

The code used:

 try
        {
            auth = new LiveAuthClient("0000000044107D80");
            LiveLoginResult result = await auth.InitializeAsync(new string[] { "wl.basic", "wl.signin", "wl.emails" });
            if (result.Status != LiveConnectSessionStatus.Connected)
            {
                result = await auth.LoginAsync(new string[] { "wl.basic", "wl.signin", "wl.emails" });
            }
            if (result.Status == LiveConnectSessionStatus.Connected)
            {
                var connect = new LiveConnectClient(auth.Session);
                var opResult = await connect.GetAsync("me");
                dynamic nameResult = opResult.Result;
                MessageBox.Show(string.Format("Welcome, {0}", nameResult.first_name));
            }
            }
        catch (Exception ex)
        {
            System.Diagnostics.Debug.WriteLine(ex.StackTrace);
        }

StackTrace:

A first chance exception of type 'Microsoft.Live.LiveAuthException' occurred in mscorlib.ni.dll
A first chance exception of type 'Microsoft.Live.LiveAuthException' occurred in mscorlib.ni.dll
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at Microsoft.Live.LiveAuthClient.<LoginAsync>d__c.MoveNext()
--- End of stack trace from previous location where exception was thrown --- at       
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at PhoneApp2.MainPage.<Login>d__4.MoveNext()

Without surrounding the login part with try/catch I get this on the debug console:

A first chance exception of type 'System.Reflection.TargetInvocationException' occurred    in mscorlib.ni.dll
A first chance exception of type 'System.Reflection.TargetInvocationException' occurred in System.Windows.ni.dll

What might be causing this type of behaviour?

neo112
  • 1,703
  • 2
  • 17
  • 39
  • Have you tried like in the solution here: http://stackoverflow.com/questions/10304150/live-sdk-try-to-sign-in-without-signinbutton ? – Romasz Dec 07 '13 at 07:43
  • I'm not able to use that approach because the LiveAuthClient doesn't have eventhandlers InitializeCompleted and LoginCompleted. Also, I dont seem to have access to LoginCompletedEventArgs. Perhaps the Live SDK components have changed since that post is over a year and targets WP7. The OP on the thread you posted doesn't appear to have the same problem as I have also.. – neo112 Dec 07 '13 at 11:09
  • Yes you are right (I've not checked that). Those events are no longer needed as you have awaitable method. On the other hand: have you tried to login with provided live:SignInButton? Or have you tried to change or recreate your client live ID for the APP? – Romasz Dec 07 '13 at 11:25
  • yes Ive tried a different ID, no help. I've had someone test the same code and ID on a different computer and it works there so it's a local issue. Also using the SignIn buttun, would't it just call the same methods etc? – neo112 Dec 07 '13 at 12:22
  • Yes SignIn should call same methods. If somewhere else it's working then it looks like network problem. If you are using Computer - maybe some kind of firewall or other protection prevents app from connecting or other settings. – Romasz Dec 07 '13 at 12:37

0 Answers0