question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Due to MonoAndroid9.0, MSAL 3.0.0 Preview Throws System.PlatformNotSupportedException on Xamarin Forms App which target MonoAndroid8.1

See original GitHub issue

Which Version of MSAL are you using ? MSAL 3.0.0-preview

Platform Xamarin Forms, testing with Android on Pixel 3 XL

What authentication flow has the issue?

  • Desktop / Mobile
    • [ x] Interactive
    • Integrated Windows Auth
    • Username Password
    • Device code flow (browserless)
  • Web App
    • Authorization code
    • OBO
  • Web API
    • OBO

Other? - please describe;

Is this a new or existing app?

c. This is a new app or experiment

Repro Created a brand new Xamarin Forms app in VS 2019 and install MSAL 3.0.0-Preview in all 3 projects.

Used the fluent api to build

PCA = PublicClientApplicationBuilder.Create(ClientID).Build();

Added the example code from here

Debug the Application.

Expected behavior The authentication flow runs throw the browser and logs the user in.

Actual behavior The following call throws an exception

result = await App.PCA.AcquireTokenInteractive(App.Scopes, null).ExecuteAsync();

Unhandled Exception: System.PlatformNotSupportedException: Possible Cause: If you are using an XForms app, or generally a netstandard assembly, make sure you add a reference to Microsoft.Identity.Client.dll from each platform assembly (e.g. UWP, Android, iOS), not just from the common netstandard assembly

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:18 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
napoleonjonescommented, Mar 7, 2019

@jennyf19 Thank you, that solved it. I had the following line commented out, probably when I was trying to diagnose on my own.

AuthenticationContinuationHelper.SetAuthenticationContinuationEventArgs(requestCode, resultCode, data);

Thank you everyone for your assistance.

1reaction
bgavrilMScommented, Mar 7, 2019

The bigger “cons” of leaving MonoAndroid 9 is supportability, because if your app is MonoAndroid8.1, the failure is very cryptic. We should at least provide a better exception.

I am also wary about developers actually wanting to target only 9, because Android API level x (Pie) has not yet gained widespread use.

I’ll look into this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Xamarin - How to update Mono.Android version to resolve ...
I'm running Visual Studio 15.6.1. As a last ditch effort, I tried deleting the Mono.Android V8.0 reference and then adding a new reference...
Read more >
Xamarin Android code configuration and troubleshooting ...
When the interactive portion of the authentication flow ends, return control to MSAL by overriding the Activity . OnActivityResult() method.
Read more >
Xamarin Android system browser considerations (MSAL. ...
If the user has no browser enabled on the device, MSAL.NET will throw an AndroidActivityNotFound exception. Mitigation: Ask the user to enable a ......
Read more >
Unable to change target framework for Android Xamarin ...
The question: how can I change the target framework version for Android Xamarin application and it will finally work?
Read more >
Migrating & Upgrading Xamarin.Forms to .NET MAUI - YouTube
Let's explore a few options of migrating apps from Xamarin. Forms to .NET MAUI. We will look at analyzing our projects, how to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found