A Microsoft platform for building and publishing apps for Windows devices.
Hi @Hong ,
The problem does not seem to be your sign-in logic anymore. The crash is happening inside WindowsProvider.GetWebTokenRequest(), when the Toolkit tries to loop through _webAccountProviderConfig.MSATokenRequestProperties.
That means the Toolkit is using a config object that was not fully initialized. So this looks more like a Toolkit bug or package/version mismatch than an issue in your app code. Reinstalling the app would not fix that.
The next thing I would try is creating WindowsProvider with an explicit WebAccountProviderConfig, and making sure the MSA and AAD token property collections are initialized before sign-in.
For example:
var webAccountProviderConfig = new WebAccountProviderConfig
{
WebAccountProviderType = WebAccountProviderType.Msa,
MSATokenRequestProperties = new Dictionary<string, string>(),
AADTokenRequestProperties = new Dictionary<string, string>()
};
var provider = new WindowsProvider(
scopes,
webAccountProviderConfig: webAccountProviderConfig,
autoSignIn: false);
That sample is only for reference, so you may need to adjust it for your project and package version.
One important detail is that the public 7.1.x docs do not clearly show these token property members, but your decompiled code does. That suggests you may be using a different build or variant of the package.
If you can edit the Toolkit source, the cleanest fix is to add null checks in GetWebTokenRequest() before looping through MSATokenRequestProperties or AADTokenRequestProperties.
At this point, I would treat this as a library issue rather than an app issue. The sign-in dialog is showing correctly, and the crash happens only after that when the Toolkit builds the token request.
If the app is still being maintained, I would also consider moving away from CommunityToolkit.Authentication.Uwp over time. MSAL with Microsoft Graph is the more reliable long-term option.