A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
Hi @Anonymous ,
Thanks for reaching out.
The exception you are seeing:
Value cannot be null. (Parameter 'ErrorCode')
occurs because MSAL.NET expected an ErrorCode value when constructing the exception, but it received null. This is not a standard login failure like wrong username or password. Instead, it indicates that MSAL encountered an internal or configuration issue while performing interactive login.
Here are some things to check and try:
- Verify your MSAL configuration Make sure your app registration, client ID, authority, and redirect URI are set correctly. For desktop/MAUI apps, the redirect URI is often:
-
https://login.microsoftonline.com/common/oauth2/nativeclient - or
msal{clientId}://authfor custom URIs Confirm this in your Azure app registration and that “public client” / “desktop/mobile” is enabled. More details here: Handle errors and exceptions in MSAL.NET.
-
- Enable MSAL logging Logging can reveal why
ErrorCodewas null and help identify the root cause. - Check the interactive flow Ensure the login UI opens properly. If using a custom webview or embedded browser, make sure it does not fail silently before MSAL can set the
ErrorCode. https://learn.microsoft.com/en-us/entra/msal/dotnet/acquiring-tokens/desktop-mobile/wam#integration-best-practices - Inspect the exception details Look at the exception type, message, stack trace, and any inner exceptions to get more context about the failure. https://learn.microsoft.com/en-us/entra/msal/dotnet/resources/troubleshooting
- Update MSAL.NET Some older MSAL versions had issues where
ArgumentNullExceptionwas thrown ifErrorCodewas null. Updating to the latest version often resolves this.
Hope this helps! If my answer was helpful - kindly follow the instructions here so others with the same problem can benefit as well.