-
Notifications
You must be signed in to change notification settings - Fork 381
Description
Library version used
4.74.1
.NET version
The issue is confirmed on both .NET 8.0 and .NET Framework 4.8.
Scenario
PublicClient - desktop app
Is this a new or an existing app?
This is a new app or experiment
Issue description and reproduction steps
Description:
When running a Windows Forms application that uses MSAL.NET for WAM authentication on an English version of Windows 10 Enterprise (Build 18363, en-US), a DllNotFoundException occurs for msalruntime.dll if the application's execution path contains non-ASCII (e.g., Japanese) characters. The authentication process works correctly if the path consists only of ASCII characters. The issue is reproducible on both .NET 8.0 and .NET Framework 4.8.
Reproduction Steps:
- Set up a development environment on an English version of Windows 10 Enterprise (Build 18363).
- Create a simple Windows Forms application (on .NET 8.0 or .NET Framework 4.8) that uses MSAL.NET to acquire a token interactively with WAM.
- Place the compiled application executable and its dependencies (including
msalruntime.dll) into a folder with a path containing Japanese characters.- Failing Path Example:
C:\テスト\MyWinFormsApp.exe
- Failing Path Example:
- Run the application and attempt to authenticate.
- Observe that the application throws a
DllNotFoundException. - Move the entire application folder to a path containing only ASCII characters.
- Working Path Example:
C:\Test\MyWinFormsApp.exe
- Working Path Example:
- Run the application again and attempt to authenticate.
- Observe that the authentication process completes successfully.
[InnerExceptions]
ErrorMessage: The type initializer for 'Microsoft.Identity.Client.NativeInterop.API' threw an exception.
StackTrace": at Microsoft.Identity.Client.NativeInterop.Module.AddRef(String handleName)
at Microsoft.Identity.Client.NativeInterop.Core..ctor()
at Microsoft.Identity.Client.Platforms.Features.RuntimeBroker.RuntimeBroker.<>c.<.cctor>b__26_0()
ErrorMessage: "Unable to load msalruntime dlls : 0",
StackTrace: at Microsoft.Identity.Client.NativeInterop.WindowsPlatformUtils.LoadLibrary(String path)
at Microsoft.Identity.Client.NativeInterop.API..cctor()
Relevant code snippets
// Standard interactive token acquisition code for a public client application.
// The issue is not in the C# code itself, but in the environment where it runs.
var app = PublicClientApplicationBuilder.Create(clientId)
.WithAuthority(authority)
.WithRedirectUri("http://localhost")
.Build();
AuthenticationResult result;
try
{
var accounts = await app.GetAccountsAsync();
result = await app.AcquireTokenSilent(scopes, accounts.FirstOrDefault())
.ExecuteAsync();
}
catch (MsalUiRequiredException)
{
// This is where the exception is thrown in the failing scenario.
// For WinForms, 'this' can be passed if called from the Form class.
result = await app.AcquireTokenInteractive(scopes)
.WithParentActivityOrWindow(this)
.ExecuteAsync();
}Expected behavior
The application should be able to load msalruntime.dll and perform WAM authentication successfully, regardless of whether the application's file path contains non-ASCII characters.
Identity provider
Microsoft Entra ID (Work and School accounts and Personal Microsoft accounts)
Regression
No, this is a new issue to me
Solution and workarounds
Workaround:
Ensure that the entire file path for the application executable and all its dependencies consists only of ASCII characters. Avoid using Japanese, accented, or other multi-byte characters in folder names.