Skip to content

[Bug] Issue with WebView2 version in .NET9 MAUI for Windows platform #5015

Closed as duplicate of#4933
@unrateddi

Description

Library version used

4.66.2

.NET version

.NET 9

Scenario

PublicClient - desktop app, PublicClient - mobile app

Is this a new or an existing app?

This is a new app or experiment

Issue description and reproduction steps

When building our .NET 9 MAUI application in Windows platform, we face issues with WebView2.
Specifically it seems that Microsoft.Client.Identity uses an older version of it than the one .NET 9 MAUI uses.
We thought we could work around it by referencing directly the older version and log-in flow works fine, but then we are unable to use a WebView control in the app since MAUI looks explicitly for the newer version. Maybe the library should reference the newer WebView2 at least for .NET 9 MAUI?

image

This can be reproduced easily in the samples of this repo by upgrading to .NET 9 and upgrading nuget packages.
Unfortunately, this is not the only issue we faced in .NET 9 MAUI, as there is another issue here that when referencing Microsoft.Identity.Client.Desktop the app won't compile. So in order to reproduce our issue you need to do the workaround mentioned here.

Repro steps:

  1. Upgrade to .NET 9
  2. Use workaround from here to be able to compile the app
  3. Disable Warnings as Errors (NU1605)
  4. Directly reference (downgrade) Microsoft.Web.WebView2 version 1.0.864.35
  5. Add a WebView control in the MainView.xaml

Relevant code snippets

<NoWarn>NU1605</NoWarn>

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


<ItemGroup>
    <DefaultReferenceExclusion Include="WindowsFormsIntegration" />
</ItemGroup>

<Target Name="RemoveWindowsFormsIntegration" BeforeTargets="MarkupCompilePass1" AfterTargets="ResolveAssemblyReferences">
    <ItemGroup>
	    <_referenceExclusion Include="@(DefaultReferenceExclusion)">
		    <AssemblyName>%(DefaultReferenceExclusion.Identity)</AssemblyName>
	    </_referenceExclusion>
	    <ReferencePath Remove="@(_referenceExclusion)" MatchOnMetadata="AssemblyName" />
    </ItemGroup>
</Target>

Expected behavior

The library and SignIn flow in .NET 9 MAUI for Windows platform should work without having to directly reference some older WebView2 version in the project.

Identity provider

Azure B2C Basic Policy

Regression

No response

Solution and workarounds

No response

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions