Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] MSAL Login does not work after upgrading to winappsdk 1.6 #4933

Open
cconner100 opened this issue Sep 18, 2024 · 36 comments · May be fixed by #5154
Open

[Bug] MSAL Login does not work after upgrading to winappsdk 1.6 #4933

cconner100 opened this issue Sep 18, 2024 · 36 comments · May be fixed by #5154

Comments

@cconner100
Copy link

Library version used

.NET version

.net 8.300. Windows App SDK 1.6

Scenario

PublicClient - desktop app

Is this a new or an existing app?

None

Issue description and reproduction steps

When our app was targeting WinAppSDK 1.5 the login would bring up the Browser login dialog box and allow us to login. After upgrading to WinAppSDK 1.6 we get the following error message and no Browser will pop up

AuthoritySignIn https://ziidmsapp.b2clogin.com/tfp/ziidmsapp.onmicrosoft.com/B2C_1A_signup_signin
AuthorityRedirectUrl msal3e2fe1b7-910e-46d2-aa0b-b1da7755d458://auth
'ZiiDMSApp.exe' (CoreCLR: clrhost): Loaded 'E:\ZiiDMS-NextGen\Client\Desktop\ZiiDMSApp\ZiiDMSApp\bin\Debug\net8.0-windows10.0.22621\AppX\Uno.Core.Extensions.Logging.Singleton.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'ZiiDMSApp.exe' (CoreCLR: clrhost): Loaded 'E:\ZiiDMS-NextGen\Client\Desktop\ZiiDMSApp\ZiiDMSApp\bin\Debug\net8.0-windows10.0.22621\AppX\CommonServiceLocator.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
PermissionsScreenName is null or empty SetPermissionControls will not be called
'ZiiDMSApp.exe' (CoreCLR: clrhost): Loaded 'E:\ZiiDMS-NextGen\Client\Desktop\ZiiDMSApp\ZiiDMSApp\bin\Debug\net8.0-windows10.0.22621\AppX\Microsoft.Identity.Client.Extensions.Msal.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'ZiiDMSApp.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.8\System.IO.FileSystem.Watcher.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'ZiiDMSApp.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.8\System.Collections.Specialized.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'ZiiDMSApp.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App\8.0.8\System.Security.Cryptography.ProtectedData.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
MSAL: Always False MSAL 4.63.0.0 MSAL.NetCore .NET 8.0.8 Microsoft Windows 10.0.22631 [2024-09-18 05:48:20Z] [Internal cache] Clearing user token cache accessor.
MSAL: Always False MSAL 4.63.0.0 MSAL.NetCore .NET 8.0.8 Microsoft Windows 10.0.22631 [2024-09-18 05:48:20Z] [Internal cache] Total number of cache partitions found while getting refresh tokens: 0
MSAL: Info False MSAL 4.63.0.0 MSAL.NetCore .NET 8.0.8 Microsoft Windows 10.0.22631 [2024-09-18 05:48:20Z - c8b05dd3-8834-4c40-b8c6-4c2718affe93] Skipping Instance discovery for B2C authority because it is not supported.
MSAL: Info False MSAL 4.63.0.0 MSAL.NetCore .NET 8.0.8 Microsoft Windows 10.0.22631 [2024-09-18 05:48:20Z - c8b05dd3-8834-4c40-b8c6-4c2718affe93] [Instance Discovery] Skipping Instance discovery for non-AAD authority.
MSAL: Info False MSAL 4.63.0.0 MSAL.NetCore .NET 8.0.8 Microsoft Windows 10.0.22631 [2024-09-18 05:48:20Z] Found 0 cache accounts and 0 broker accounts
MSAL: Info False MSAL 4.63.0.0 MSAL.NetCore .NET 8.0.8 Microsoft Windows 10.0.22631 [2024-09-18 05:48:20Z] Returning 0 accounts
MSAL: Always False MSAL 4.63.0.0 MSAL.NetCore .NET 8.0.8 Microsoft Windows 10.0.22631 [2024-09-18 05:48:20Z] [Internal cache] Clearing user token cache accessor.
MSAL: Always False MSAL 4.63.0.0 MSAL.NetCore .NET 8.0.8 Microsoft Windows 10.0.22631 [2024-09-18 05:48:20Z] [Internal cache] Total number of cache partitions found while getting refresh tokens: 0
MSAL: Info False MSAL 4.63.0.0 MSAL.NetCore .NET 8.0.8 Microsoft Windows 10.0.22631 [2024-09-18 05:48:20Z - 7cba51d7-3401-482e-adcc-44d1dcd6f61d] Skipping Instance discovery for B2C authority because it is not supported.
MSAL: Info False MSAL 4.63.0.0 MSAL.NetCore .NET 8.0.8 Microsoft Windows 10.0.22631 [2024-09-18 05:48:20Z - 7cba51d7-3401-482e-adcc-44d1dcd6f61d] [Instance Discovery] Skipping Instance discovery for non-AAD authority.
MSAL: Info False MSAL 4.63.0.0 MSAL.NetCore .NET 8.0.8 Microsoft Windows 10.0.22631 [2024-09-18 05:48:20Z] Found 0 cache accounts and 0 broker accounts
MSAL: Info False MSAL 4.63.0.0 MSAL.NetCore .NET 8.0.8 Microsoft Windows 10.0.22631 [2024-09-18 05:48:20Z] Returning 0 accounts
MSAL: Info False MSAL 4.63.0.0 MSAL.NetCore .NET 8.0.8 Microsoft Windows 10.0.22631 [2024-09-18 05:48:20Z - a3957b6e-b482-44c7-8a4c-a7218dbcb4c2] MSAL MSAL.NetCore with assembly version '4.63.0.0'. CorrelationId(a3957b6e-b482-44c7-8a4c-a7218dbcb4c2)
MSAL: Info False MSAL 4.63.0.0 MSAL.NetCore .NET 8.0.8 Microsoft Windows 10.0.22631 [2024-09-18 05:48:20Z - a3957b6e-b482-44c7-8a4c-a7218dbcb4c2] === AcquireTokenSilent Parameters ===
MSAL: Info False MSAL 4.63.0.0 MSAL.NetCore .NET 8.0.8 Microsoft Windows 10.0.22631 [2024-09-18 05:48:20Z - a3957b6e-b482-44c7-8a4c-a7218dbcb4c2] LoginHint provided: False
MSAL: Info False MSAL 4.63.0.0 MSAL.NetCore .NET 8.0.8 Microsoft Windows 10.0.22631 [2024-09-18 05:48:20Z - a3957b6e-b482-44c7-8a4c-a7218dbcb4c2] Account provided: False
MSAL: Info False MSAL 4.63.0.0 MSAL.NetCore .NET 8.0.8 Microsoft Windows 10.0.22631 [2024-09-18 05:48:20Z - a3957b6e-b482-44c7-8a4c-a7218dbcb4c2] ForceRefresh: False
MSAL: Info False MSAL 4.63.0.0 MSAL.NetCore .NET 8.0.8 Microsoft Windows 10.0.22631 [2024-09-18 05:48:20Z - a3957b6e-b482-44c7-8a4c-a7218dbcb4c2]
=== Request Data ===
Authority Provided? - True
Scopes - https://XXXX/access_as_user
Extra Query Params Keys (space separated) -
ApiId - AcquireTokenSilent
IsConfidentialClient - False
SendX5C - False
LoginHint ? False
IsBrokerConfigured - False
HomeAccountId - False
CorrelationId - a3957b6e-b482-44c7-8a4c-a7218dbcb4c2
UserAssertion set: False
LongRunningOboCacheKey set: False
Region configured:

MSAL: Info False MSAL 4.63.0.0 MSAL.NetCore .NET 8.0.8 Microsoft Windows 10.0.22631 [2024-09-18 05:48:20Z - a3957b6e-b482-44c7-8a4c-a7218dbcb4c2] === Token Acquisition (SilentRequest) started:
Scopes: https://XXXXX/access_as_user
'ZiiDMSApp.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.8\System.Reflection.Metadata.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
MSAL: Error False MSAL 4.63.0.0 MSAL.NetCore .NET 8.0.8 Microsoft Windows 10.0.22631 [2024-09-18 05:48:20Z - a3957b6e-b482-44c7-8a4c-a7218dbcb4c2] Exception type: Microsoft.Identity.Client.MsalUiRequiredException
, ErrorCode: user_null
HTTP StatusCode 0
CorrelationId a3957b6e-b482-44c7-8a4c-a7218dbcb4c2
To see full exception details, enable PII Logging. See https://aka.ms/msal-net-logging
at Microsoft.Identity.Client.Internal.Requests.Silent.SilentRequest.ExecuteAsync(CancellationToken cancellationToken)
at Microsoft.Identity.Client.Internal.Requests.RequestBase.<>c__DisplayClass11_1.<b__1>d.MoveNext()
--- End of stack trace from previous location ---
at Microsoft.Identity.Client.Utils.StopwatchService.MeasureCodeBlockAsync(Func`1 codeBlock)
at Microsoft.Identity.Client.Internal.Requests.RequestBase.RunAsync(CancellationToken cancellationToken)

Exception thrown: 'Microsoft.Identity.Client.MsalUiRequiredException' in System.Private.CoreLib.dll
MSAL: Info False MSAL 4.63.0.0 MSAL.NetCore .NET 8.0.8 Microsoft Windows 10.0.22631 [2024-09-18 05:48:20Z - 110bfb27-5e09-4fd8-8b2a-7a74a85ec1b6] MSAL MSAL.NetCore with assembly version '4.63.0.0'. CorrelationId(110bfb27-5e09-4fd8-8b2a-7a74a85ec1b6)
MSAL: Info False MSAL 4.63.0.0 MSAL.NetCore .NET 8.0.8 Microsoft Windows 10.0.22631 [2024-09-18 05:48:20Z - 110bfb27-5e09-4fd8-8b2a-7a74a85ec1b6] === InteractiveParameters Data ===
LoginHint provided: False
User provided: False
UseEmbeddedWebView: NotSpecified
ExtraScopesToConsent:
Prompt: login
HasCustomWebUi: False
MSAL: Info False MSAL 4.63.0.0 MSAL.NetCore .NET 8.0.8 Microsoft Windows 10.0.22631 [2024-09-18 05:48:20Z - 110bfb27-5e09-4fd8-8b2a-7a74a85ec1b6]
=== Request Data ===
Authority Provided? - True
Scopes - https:/XXXXXXX/access_as_user
Extra Query Params Keys (space separated) -
ApiId - AcquireTokenInteractive
IsConfidentialClient - False
SendX5C - False
LoginHint ? False
IsBrokerConfigured - False
HomeAccountId - False
CorrelationId - 110bfb27-5e09-4fd8-8b2a-7a74a85ec1b6
UserAssertion set: False
LongRunningOboCacheKey set: False
Region configured:

MSAL: Info False MSAL 4.63.0.0 MSAL.NetCore .NET 8.0.8 Microsoft Windows 10.0.22631 [2024-09-18 05:48:20Z - 110bfb27-5e09-4fd8-8b2a-7a74a85ec1b6] === Token Acquisition (InteractiveRequest) started:
Scopes: https://ZiiDMSAPP.onmicrosoft.com/ZiiDMSWebApi/access_as_user
MSAL: Info False MSAL 4.63.0.0 MSAL.NetCore .NET 8.0.8 Microsoft Windows 10.0.22631 [2024-09-18 05:48:20Z - 110bfb27-5e09-4fd8-8b2a-7a74a85ec1b6] [Instance Discovery] Skipping Instance discovery for non-AAD authority.
MSAL: Error False MSAL 4.63.0.0 MSAL.NetCore .NET 8.0.8 Microsoft Windows 10.0.22631 [2024-09-18 05:48:20Z - 110bfb27-5e09-4fd8-8b2a-7a74a85ec1b6] Exception type: System.IO.FileNotFoundException
To see full exception details, enable PII Logging. See https://aka.ms/msal-net-logging
at Microsoft.Identity.Client.Desktop.WebView2WebUi.WebView2WebUiFactory.IsWebView2Available()
at Microsoft.Identity.Client.Desktop.WebView2WebUi.WebView2WebUiFactory.CreateAuthenticationDialog(CoreUIParent coreUIParent, WebViewPreference useEmbeddedWebView, RequestContext requestContext)
at Microsoft.Identity.Client.Internal.AuthCodeRequestComponent.CreateWebAuthenticationDialog()
at Microsoft.Identity.Client.Internal.AuthCodeRequestComponent.FetchAuthCodeAndPkceVerifierAsync(CancellationToken cancellationToken)
at Microsoft.Identity.Client.Internal.Requests.InteractiveRequest.GetTokenResponseAsync(CancellationToken cancellationToken)
at Microsoft.Identity.Client.Internal.Requests.InteractiveRequest.ExecuteAsync(CancellationToken cancellationToken)
at Microsoft.Identity.Client.Internal.Requests.RequestBase.<>c__DisplayClass11_1.<b__1>d.MoveNext()
--- End of stack trace from previous location ---
at Microsoft.Identity.Client.Utils.StopwatchService.MeasureCodeBlockAsync(Func`1 codeBlock)
at Microsoft.Identity.Client.Internal.Requests.RequestBase.RunAsync(CancellationToken cancellationToken)

Exception thrown: 'System.IO.FileNotFoundException' in System.Private.CoreLib.dll
Could not load file or assembly 'Microsoft.Web.WebView2.Core, Version=1.0.864.35, Culture=neutral, PublicKeyToken=2a8ab48044d2601e'. The system cannot find the file specified.

Relevant code snippets

No response

Expected behavior

Expect it to work like the WinAppSDK 1.5 version which popups the login window

Identity provider

Azure B2C Custom Policy

Regression

No response

Solution and workarounds

No response

@cconner100 cconner100 added needs attention Delete label after triage untriaged Do not delete. Needed for Automation labels Sep 18, 2024
@cconner100
Copy link
Author

If i change my code to use WithDefaultREdirectUri and not with the browserredirect it works. But it would be nice to have the older code work again

@iulico-1 iulico-1 removed the untriaged Do not delete. Needed for Automation label Oct 15, 2024
@CameronVetter
Copy link

Any plan for this? This is a complete showstopper for existing applications. I can't believe this isn't urgent enough that your team hasn't even bothered to respond to this issue.

@localden
Copy link
Collaborator

localden commented Nov 11, 2024

@CameronVetter investigation is ongoing. We have a repro that we're lookin at the best way to address.

@panta2705
Copy link

Any news here?
We have same issue that msal library requires old version of Microsoft.Web.WebView2 on dotnet 9. Because latest (v9.0.10) maui library Microsoft.Maui.Core now includes new Microsoft.WindowsAppSDK as well as Microsoft.Web.WebView2 directly now so our sign in process is broken and our migration to dotnet 9 blocked by this
image

@localden
Copy link
Collaborator

localden commented Dec 2, 2024

@panta2705 - can you walk me through your repro steps, along with the snippet of code that you are using to authenticate?

I am testing this as we speak with MAUI and .NET 9 and so far not running into the issue you are calling out.

@localden
Copy link
Collaborator

localden commented Dec 2, 2024

@cconner100 @CameronVetter can you also please provide the code snippets that you are using that are triggering this? From my testing it seems contained to B2C scenarios.

@CameronVetter
Copy link

I can confirm my scenario is a B2C application. Here are my packages:

<ItemGroup>
        <PackageReference Include="Azure.Storage.Queues" Version="12.20.1" />
        <PackageReference Include="BlazorTransitionableRoute" Version="4.0.0" />
        <PackageReference Include="CommunityToolkit.Maui" Version="9.1.1" />
        <PackageReference Include="CommunityToolkit.Mvvm" Version="8.3.2" />
        <PackageReference Include="Kebechet.Maui.RevenueCat.InAppBilling" Version="4.5.3" />
        <PackageReference Include="Microsoft.ApplicationInsights.WorkerService" Version="2.22.0" />
        <PackageReference Include="Microsoft.AspNetCore.Components" Version="8.0.10" />
        <PackageReference Include="Microsoft.AspNetCore.Components.Authorization" Version="8.0.10" />
        <PackageReference Include="Microsoft.AspNetCore.Components.WebView.Maui" Version="8.0.93" />
        <PackageReference Include="Microsoft.Extensions.Logging.ApplicationInsights" Version="2.22.0" />
        <PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.1" />
        <PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.1" />
        <PackageReference Include="Microsoft.Extensions.Logging.abstractions" Version="8.0.2" />
        <PackageReference Include="Microsoft.Identity.Client" Version="4.66.1" />
        <PackageReference Include="Microsoft.Identity.Client.Desktop" Version="4.66.1" Condition="'$(TargetFramework)' == 'net8.0-windows10.0.19041.0'" />
        <PackageReference Include="Microsoft.Identity.Client.Extensions.Msal" Version="4.66.1" />
        <PackageReference Include="Microsoft.Maui.Controls" Version="8.0.93" />
        <PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="8.0.93" />
        <PackageReference Include="Microsoft.Web.WebView2" Version="1.0.2849.39" Condition="'$(TargetFramework)' == 'net8.0-windows10.0.19041.0'" />
        <PackageReference Include="Microsoft.WindowsAppSDK" Version="1.6.240923002" Condition="'$(TargetFramework)' == 'net8.0-windows10.0.19041.0'" />
        <PackageReference Include="MudBlazor" Version="7.15.0" />
        <PackageReference Include="MudBlazor.Markdown" Version="7.14.0" />
        <PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
        <PackageReference Include="Polly" Version="8.4.2" />
        <PackageReference Include="RestSharp" Version="112.1.0" />
        <PackageReference Include="RestSharp.Serializers.NewtonsoftJson" Version="112.1.0" />
        <PackageReference Include="System.Diagnostics.PerformanceCounter" Version="8.0.1" />
    </ItemGroup>

and the code that triggers the error is (greatly simplified):

            PublicClientApplication = PublicClientApplicationBuilder
                .WithWindowsEmbeddedBrowserSupport()
                .WithRedirectUri($"https://bgcopilot.b2clogin.com/oauth2/nativeclient")
                .Build();

                return await PublicClientApplication.AcquireTokenInteractive(AzureADB2CConfig.Scopes)
                   .WithUseEmbeddedWebView(true)
                   .ExecuteAsync();

@localden
Copy link
Collaborator

localden commented Dec 3, 2024

I am running this as a test:

var app = PublicClientApplicationBuilder.Create("foobar")
   .WithWindowsEmbeddedBrowserSupport()
   .WithRedirectUri($"https://bgcopilot.b2clogin.com/oauth2/nativeclient")
   .Build();

var t = await app.AcquireTokenInteractive(new string[]{ "user.read" })
   .WithUseEmbeddedWebView(true)
   .ExecuteAsync();

I do not see any errors and the web view correctly shows. This targets net-8.0, by the way - net9.0 has a different blocking bug (dotnet/maui#25883) that prevents me from testing it.

What version of Windows are you running? Can you also please upgrade to the latest MSAL?

@CameronVetter
Copy link

I'm running the latest version of Windows 11:

image

I tried updating to 4.66.2 which is latest and still have the same filenotfound exception

@panta2705
Copy link

@localden Here is some simplified code snippets, I can try making a sample project with the issue if needed

public AuthenticationProvider()
{
	var builder = PublicClientApplicationBuilder
		.Create(_config.ClientId)
		.WithIosKeychainSecurityGroup(_config.IOSKeychainSecurityGroup)
		.WithB2CAuthority(_config.AuthoritySignInUp)
		.WithRedirectUri($"msal{_config.ClientId}://auth");
		
	#if WINDOWS
		builder.WithWindowsEmbeddedBrowserSupport();
	#endif

		_pca = builder.Build();

	#if WINDOWS
		var storageProperties =
			new StorageCreationPropertiesBuilder("msal-cache", storageSettings.MsalCacheDirectory)
				.Build();

		// This hooks up the cross-platform cache into MSAL
		var cacheHelper = MsalCacheHelper.CreateAsync(storageProperties);
		cacheHelper.Result.RegisterCache(_pca.UserTokenCache);
	#endif
}

public Task<AuthenticationResult> SignInAsync(string emailHint)
{
    return _pca!.AcquireTokenInteractive(_config!.Scopes)
		.WithB2CAuthority(_config.AuthoritySignInUp)
#if ANDROID || IOS
        .WithUseEmbeddedWebView(true)
#endif
        .WithPrompt(Prompt.ForceLogin)
        .WithLoginHint(emailHint)
        .WithExtraQueryParameters(_extraQueryParams)
        .ExecuteAsync()
        .WrapMsalExceptionsAsync();
}

Respective libs used that produce error

<PackageVersion Include="CommunityToolkit.Maui" Version="9.1.1" />
<PackageVersion Include="Microsoft.Identity.Client" Version="4.66.2" />
<PackageVersion Include="Microsoft.Identity.Client.Desktop" Version="4.66.2" />
<PackageVersion Include="Microsoft.Identity.Client.Extensions.Msal" Version="4.66.2" />
<PackageVersion Include="Microsoft.Maui.Controls" Version="9.0.10" />
<PackageVersion Include="Microsoft.Maui.Controls.Compatibility" Version="9.0.10" />
<PackageVersion Include="Microsoft.AspNetCore.Components.WebView.Maui" Version="9.0.10" />

Respective libs used that are working

<PackageVersion Include="CommunityToolkit.Maui" Version="9.1.1" />
<PackageVersion Include="Microsoft.Identity.Client" Version="4.66.2" />
<PackageVersion Include="Microsoft.Identity.Client.Desktop" Version="4.66.2" />
<PackageVersion Include="Microsoft.Identity.Client.Extensions.Msal" Version="4.66.2" />
<PackageVersion Include="Microsoft.Maui.Controls" Version="8.0.100" />
<PackageVersion Include="Microsoft.Maui.Controls.Compatibility" Version="8.0.100" />
<PackageVersion Include="Microsoft.AspNetCore.Components.WebView.Maui" Version="8.0.100" />

Windows version
image

@localden
Copy link
Collaborator

localden commented Dec 3, 2024

Thank you, folks - will be running a few more tests today to see if I can reproduce this reliably.

@ancker1
Copy link

ancker1 commented Dec 17, 2024

We observe the same problem in our applications

@mibinoob
Copy link

mibinoob commented Dec 17, 2024

Is there any updates on this @localden?
We have had this issue trying to upgrade our WinUI3 application from .Net6 to 8, Sdk 1.2.230118.102 to 1.6.241114003 and WebView2 to 1.0.2903.40.
When attempting to login we get
System.IO.FileNotFoundException: 'Could not load file or assembly 'Microsoft.Web.Webview2.Core, Version=1.0.864.35, Culture=neutral, PublicKeyToken=2a8ab48044d2601e'. The system cannot find the file specified.'

Our only fix so far is keeping .NET SDK as 1.2 and downgrading WebView2 to 1.0.864.35 which seems asenine.

Edit: Did some more digging, as I could not remember former WebView2 version:
Webview2 had to be introduced when updating Microsoft.Identity.Client.Extensions.Msal from 4.60.x to 4.66.x as we had to utilize Microsoft.Identity.Client.Desktop (this was initially no problem on .Net6). However when upgrading to .Net8 as stated earlier the problems came crashing down and we cannot upgrade our applications from .Net6 to 8, which is uncomfortable since Microsoft no longer supports .Net6

@CameronVetter
Copy link

Any updates @localden? I'm still seeing this problem and blocked from releasing on Windows. Were you able to repro this locally? It's been many months without any progress on this critical showstopper! What is the timeline for getting this fixed?

@localden
Copy link
Collaborator

localden commented Jan 9, 2025

We're still working on a repro for this. @CameronVetter @mibinoob @ancker1 - what would be most helpful at this time is if you have a "minimum reproducible project." It can be a simple app that shows the behavior reliably, that you can attach to the issue.

There are clearly conflicting dependencies, but I am trying to pinpoint the exact conditions under which those cause issues.

@unrateddi
Copy link

Hi @localden you can use my sample to reproduce the issue with the old WebView version referenced by ms-auth. It is just a fork of ms-identity-dotnetcore-maui samples, upgraded to net9 and updated all nuget packages to latest. Also added the csproj workaround to be able to build in windows because of this issue (described in more detail in my issue #5015 ).
repro-version-notfound

Please use the MauiAppBasic project, fill-in the appsettings.json with auth info. The app should be run on Windows platform as the issue is only relevant for Windows. Make sure that you select the Use Embedded checkbox in the app before you hit "Sign In".
image

You should end-up with the error:
image

To add, you can also look into this branch, which directly references the version the error mentions and the auth works now, but we are unable to use any WebView control in MAUI-Windows because it looks up for a newer version giving the following error. After successfully login with "Use Embedded" option the app goes to the UserView page which I have place a WebView control.

image

@CameronVetter
Copy link

Has anyone come up with a workaround for this? As of yesterday I now have two apps that are blocked due to this bug...

@espenrl
Copy link

espenrl commented Jan 13, 2025

Microsoft.Identity.Client.Desktop uses an older version of Microsoft.Web.WebView2. 1.0.864.35 was released June 1st 2021.

<PackageVersion Include="Microsoft.Web.WebView2" Version="1.0.864.35" />

The DLL structure has changed (though Microsoft.Web.WebView2.Core.dll is present in both). Please see internals of packages

There is probably a binary/API incompatibility between the older and newer version.

@localden
Copy link
Collaborator

@iulico-1 @ashok672 seems like the issue is indeed caused by what @unrateddi and @espenrl called out (older version of Microsoft.Web.WebView2 dependency). We should prioritize updating it to avoid the current issue in WinUI/.NET 9 applications.

@ashok672 ashok672 removed the needs attention Delete label after triage label Jan 14, 2025
@unrateddi unrateddi marked this as a duplicate of #5015 Jan 18, 2025
@lukaszzielnica
Copy link

When a bugfix is planned to be released?

@localden
Copy link
Collaborator

@lukaszzielnica - will delegate this decision to @iulico-1 and @ashok672, as I am no longer in the security side of the house.

@localden localden assigned ashok672 and iulico-1 and unassigned localden Jan 23, 2025
@espenrl
Copy link

espenrl commented Jan 26, 2025

@localden @iulico-1 @ashok672 Can this issue be prioritized as this hinder the use of MAUI on Windows with .NET 9. All three technologies are Microsoft products within active support. It has been known since September 18th and a fix would be much welcomed.

@ancker1
Copy link

ancker1 commented Jan 29, 2025

@lukaszzielnica @iulico-1 @ashok672 Can this issue be prioritized as this hinder the use of MAUI on Windows with .NET 9. All three technologies are Microsoft products within active support. It has been known since September 18th and a fix would be much welcomed.

+1
I hope you are able to prioritize this issue.

@CameronVetter
Copy link

+2
Please prioritize, and I certainly hope you will fix the testing gap that allowed this to ship in a broken state, it clearly was never tested.

@dtentori
Copy link

same error here with MAUI Hybrid Blazor + .NET 9 + Windows target. Please prioriize

@SimonDutton
Copy link

I have raised an issue on MS Developer Community as I am also getting this problem since upgrading to .Net 9 and it includes an Example .Net 8 app that works and a .Net 9 one that does not.

https://developercommunity.visualstudio.com/t/DotNet-9-PublicClientApplication-Microso/10841011

@ancker1
Copy link

ancker1 commented Feb 10, 2025

@localden @iulico-1 @ashok672 are you able to provide an update on this issue?

@ashok672
Copy link
Contributor

ashok672 commented Feb 10, 2025

We will work on the fix this week. Will update when there is something to share.

@DharshanBJ
Copy link
Contributor

DharshanBJ commented Feb 14, 2025

@unrateddi , we haven't been able to reproduce this issue, even with the sample repo you provided (.NET 9/WinAppSDK 1.6). Are you still encountering this problem with the latest versions of .net9/Microsoft.Identity.Client.Desktop packages?

As mentioned here - https://www.nuget.org/packages/Microsoft.Identity.Client.Desktop#dependencies-body-tab, the required version of WebView2 is >= 1.0.864.35, so it should work for the newer versions of webview2 as well, we're unsure what might be causing this issue.

Since 1.0.864.35 is an very older version of WebView2, we're working on upgrading it to a newer version, but we're not sure yet if that will resolve the issue.

@unrateddi
Copy link

@DharshanBJ , yes this is still reproducible in my sample repo even with the latest packages. I just pushed a commit with all nugets updated.

Please confirm you are trying to reproduce it on the correct branch as mentioned in my post. The branch name is repro-version-notfound. Repro should be pretty easy on MauiAppBasic project like fill in appsettings.json with auth info, build, run, click "Use Embedded" checkbox, click "Sign in" button and then the exception should be thrown mentioning that version 1.0.864.35 of the dll is not found.

Also you might need to enable System.IO.FileNotFoundException in Exception Settings in Visual Studio to get proper exception insights.

@SimonDutton
Copy link

I have added a simple VS Solution containing a .Net8 and a .Net9 version of the same project. The .Net8 works but the .Net9 does not.
MauiMSAL-Test.zip

if you try the .Net9 version you get this error : 'Could not load file or assembly 'Microsoft.Web.WebView2.Core, Version=1.0.864.35, Culture=neutral, PublicKeyToken=2a8ab48044d2601e'. The system cannot find the file specified.'

Image

@Forestbrook
Copy link

Forestbrook commented Feb 14, 2025

We also still have this issue, please fix it ASAP!
This is an urgent issue for us, because we need nuget packages with fixes only available in the .NET9 version in our app.

We get this exception message when logging on:
Could not load file or assembly 'Microsoft.Web.WebView2.Core, Version=1.0.864.35, Culture=neutral, PublicKeyToken=2a8ab48044d2601e'. The system cannot find the file specified.

This is interestingly, because the Microsoft.Client.IdentityDesktop package states it needs Microsoft.Web.WebView2 >= 1.0.864.35, so it should work with Microsoft.Web.WebView2 version 1.0.2792.45 or higher

The problem in both situations is the DLL reference:
1.0.864.35 is using Microsoft.Web.WebView2.Core
1.0.2792.45 and later is using Microsoft.Web.WebView2.Core.Projection

So please fix the direct reference to the dll!

@dtentori
Copy link

I confirm reported issues and comments. We're developing a project in MAUI Hybrid Blazor with "net9" with MSAL interactive auth and this bug forces us to target "net8" in the whole project.
Please solve, thanks

@unrateddi
Copy link

Hello @DharshanBJ , any updates on this? We are 3 months in .NET9 with having to decide if we want working ms-auth or webview in MAUI Windows.

@ancker1
Copy link

ancker1 commented Feb 24, 2025

@localden @iulico-1 @ashok672 any news?

For us developers it is hard to understand how this issue is not prioritized higher.

@DharshanBJ
Copy link
Contributor

I have added a simple VS Solution containing a .Net8 and a .Net9 version of the same project. The .Net8 works but the .Net9 does not. MauiMSAL-Test.zip

if you try the .Net9 version you get this error : 'Could not load file or assembly 'Microsoft.Web.WebView2.Core, Version=1.0.864.35, Culture=neutral, PublicKeyToken=2a8ab48044d2601e'. The system cannot find the file specified.'

Image

Thanks simon for sharing your sample, we are able to repro this issue using your sample app now.
I'm actively working on implementing a fix for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet