3

What I'm trying to do:

For the UWP app that I'm developing, I'm requiring the users to login with their Google/FB credentials to access the features of the app. To do this, I'm using an Auth0 client for OAuth authentication. On successful login, the user should be navigated to MainPage.xaml. When debugging the app, this works perfectly with no problems at all.

XAML:

<Button Margin="0,45,0,0" Grid.Row="6" HorizontalAlignment="Center" Name="GoogleSignIn" Content="Sign in with Google+" Tag="google-oauth2" Click="OAuthSignin" />
<Button Margin="0,15,0,0" Grid.Row="7" HorizontalAlignment="Center" Name="FacebookSignIn" Content="Sign in with Facebook" Tag="facebook" Click="OAuthSignin" />

Code-behind:

private async void OAuthSignin(object sender, RoutedEventArgs e)
{
    string oauthprovider = ((Button)sender).Tag.ToString();
    try
        {
            Auth0User user = await App.auth0.LoginAsync(oauthprovider);

            if (user != null)
            {
                //Add user to credential locker
            }
        }
        catch(Exception ex)
        {
            ex.ToString();
        }
        finally
        {
            var nav = Template10.Common.BootStrapper.Current.NavigationService;
            nav.Navigate(typeof(Views.MainPage));
            nav.ClearHistory();
        }
}

What's going wrong:

Since the app gets deployed to the emulator, I stop debugging and launch the app by tapping the tile. I get to the login page, enter my credentials. As soon as I hit enter, I see it returning back to the login page and crashing soon after. If I re-open the app this point, I see that I'm already logged in and it takes me directly to MainPage.xaml (as is the logic of the app)

What concerns me: Why is it behaving differently when not in debug mode? This handicaps me because I can't put a breakpoint to determine what caused the crash.

Any input would be greatly appreciated.

P.S: I've tried deploying the app to me Lumia 640 and I see the same problem on the phone as well (meaning to say it's not emulator related). The desktop version works fine (even outside of debugging).

Jason Bourne
  • 349
  • 1
  • 3
  • 14
  • Try enabling "Compile with .NET Native tool chain" for debug configuration and see if it crashes then too: http://stackoverflow.com/questions/34829321/install-an-appx-or-appxbundle-in-a-windows-phone-10/34836628#34836628 – Gaurav Mar 04 '16 at 06:03
  • 1
    One of the differences between debug and release is that PLM is disabled and app is not suspended (I will also try to search there, as on desktop as you have said there is no problem - on desktop app is not suspended). How your login process look like? Do you use webauthentication broker? In debug mode, if you need to suspend your app, take a look [at this answer](http://stackoverflow.com/a/24103734/2681948). – Romasz Mar 04 '16 at 06:29
  • @Romasz, The Auth0 client uses WebAuthenticationBroker. Suspending the app is not a problem. When I'm not debugging and and launching the app (on emulator or a real phone) it crashes soon after the await App.auth0.LoginAsync(oauthprovider); statement. – Jason Bourne Mar 04 '16 at 17:04

1 Answers1

0

I had this problems before.

I solved this issue debugging my app using the new feature for debugging uwp apps in VS2015. you need to debug your app in pre launch mode.

I recommend you select

Don't launch, but debug my app option

https://blogs.msdn.microsoft.com/visualstudioalm/2015/11/30/debug-uwp-prelaunch-with-vs2015/

RicardoPons
  • 1,323
  • 9
  • 14