Xamarin Forms MSAL Hangs

Fritz Switzer 241 Reputation points
2020-07-04T14:35:06.717+00:00

In my Xamarin Forms app using MSAL, the UWP project runs and authenticates as expected. However, the Android project "hangs" after the sign-in is partially completed. "Sign In", "Are You Trying " screen, then hangup, …. With the UWP project, "Sign In" and then project continues.

If I created an app with a Blank Template and just a single Main Page, my code works correctly, the user is Authenticated and program completes as expected. However, if I change the program to a Tabbed Template with multiple pages, the program "hangs" during Authentication.

I have added the code to the Android MainActivity.cs file.

I've tried to change the line with the following because this is where I'm stuck.

> global::Xamarin.Forms.Forms.Init(this, bundle);
LoadApplication(new App());
App.ParentWindow = this

Here is my MainActivity.cs

> [Activity(Label = "MyEMR", Icon = "@mipmap/icon", Theme = "@STYLE /MainTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
{

    protected override void OnCreate(Bundle bundle)  
    {  
        base.OnCreate(bundle);  

        global::Xamarin.Forms.Forms.Init(this, bundle);  
        LoadApplication(new App());  
        App.ParentWindow = this;  
    }  

    public override void OnRequestPermissionsResult(int requestCode, string[] permissions, [GeneratedEnum] Android.Content.PM.Permission[] grantResults)  
    {  
        Xamarin.Essentials.Platform.OnRequestPermissionsResult(requestCode, permissions, grantResults);  

        base.OnRequestPermissionsResult(requestCode, permissions, grantResults);  
    }  

    protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)  
    {  
        base.OnActivityResult(requestCode, resultCode, data);  
        AuthenticationContinuationHelper.SetAuthenticationContinuationEventArgs(requestCode, resultCode, data);  
    }  

}  
Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
19,383 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Leon Laude 85,646 Reputation points
    2020-07-04T14:48:34.743+00:00

    Hi,

    Xamarin is currently not supported in the Q&A forums, the supported products are listed over here https://learn.microsoft.com/en-us/answers/products (more to be added later on).

    You can ask the experts in the dedicated Xamarin forum over here:
    https://forums.xamarin.com/

    (Please don't forget to accept helpful replies as answer)

    Best regards,
    Leon

    1 person found this answer helpful.
    0 comments No comments