microsoft-authentication-library-for-dotnet: Upgrade from MSAL v1.0 to MSAL v2.0+ iOS - Object reference not set to an instance of an object

name: Bug report about: Create a report to help us improve

Which Version of MSAL are you using ? 2.3.1

Which platform has the issue? Xamarin iOS

What authentication flow has the issue?

  • Mobile
    • Xamarin.iOS

What is the identity provider ?

  • Azure AD B2C

If B2C, what social identity did you use? Email


I am using a clean Xamarin Forms project file I implement the MSAL library LOWER than version 2.0 I implement the simplest possible interaction with MSAL (see code snippet below): The app works as expected on iOS and Android, launching the login page I update MSAL to any version higher than 2.0 I follow the instructions to add <CodesignEntitlements>Entitlements.plist</CodesignEntitlements> I enable keychain access and specify I clean and rebuild the app Now instead of launching the login page, the exception ‘Object reference not set to an instance of an object’ is triggered Upgrading Android does not result in this error I have also attempted to use a later version of MSAL 2.0 in at least two code samples on GitHub and both fail in similar ways even after making the keychain changes

                    authenticationResult = await ADB2CClient.AcquireTokenAsync(

Expected behavior iOS should still launch the login page.

Actual behavior Object reference not set to an instance of an object’

Additional context/ Logs / Screenshots


AuthTest.Authenticate.LoginPage.Handle_Clicked() in /Users/dbrickley/Projects/AuthTest/AuthTest/Authenticate/LoginPage.xaml.cs:31 System.Runtime.CompilerServices.AsyncVoidMethodBuilder.Start<AuthTest.Authenticate.LoginPage.<Handle_Clicked>d__4>(AuthTest.Authenticate.LoginPage stateMachine) in /Library/Frameworks/Xamarin.iOS.framework/Versions/ AuthTest.Authenticate.LoginPage.Handle_Clicked(Xamarin.Forms.Button sender, System.EventArgs e) in Xamarin.Forms.Button.SendClicked() in D:/a/1/s/Xamarin.Forms.Core/Button.cs:133 Xamarin.Forms.Platform.iOS.ButtonRenderer.OnButtonTouchUpInside(UIKit.UIButton sender, System.EventArgs eventArgs) in UIKit.UIControlEventProxy.Activated() in /Library/Frameworks/Xamarin.iOS.framework/Versions/ UIKit.UIApplication.UIApplicationMain() in UIKit.UIApplication.Main(string[] args, System.IntPtr principal, System.IntPtr delegate) in /Library/Frameworks/Xamarin.iOS.framework/Versions/ UIKit.UIApplication.Main(string[] args, string principalClassName, string delegateClassName) in /Library/Frameworks/Xamarin.iOS.framework/Versions/ AuthTest.iOS.Application.Main(string[] args) in /Users/dbrickley/Projects/AuthTest/AuthTest.iOS/Main.cs:17

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 21 (5 by maintainers)

Most upvoted comments

Thanks @Journeyman42 - glad it was a quick fix. Here’s our documentation on the UIParent for iOS in case others stumble upon this issue as well.