A first chance exception of type 'Microsoft.Live.LiveAuthException' occurred in mscorlib.ni.dll

醉酒当歌 提交于 2019-12-11 07:19:46

问题


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?

来源:https://stackoverflow.com/questions/20435515/a-first-chance-exception-of-type-microsoft-live-liveauthexception-occurred-in

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!