WebView2 types exist in both Microsoft.Web.WebView2.Core and Microsoft.WinUI
See original GitHub issueI have a .NET 5 desktop app with WinUI 3 and these are some of the package references
I am getting this build error:
error CS0433: The type 'CoreWebView2NavigationStartingEventArgs' exists in both 'Microsoft.Web.WebView2.Core, Version=1.0.864.35, Culture=neutral, PublicKeyToken=2a8ab48044d2601e' and 'Microsoft.WinUI, Version=3.0.0.0, Culture=neutral, PublicKeyToken=de31ebe4ad15742b'
The following code is causing the issue, since the type CoreWebView2NavigationStartingEventArgs
exists in both Microsoft.WinUI
and Microsoft.Web.WebView2.Core
:
private void AuthWebView_NavigationStarting(WebView2 sender, Microsoft.Web.WebView2.Core.CoreWebView2NavigationStartingEventArgs args)
{
var destination = args.Uri;
if (destination.StartsWith(this.Callback, StringComparison.OrdinalIgnoreCase))
{
args.Cancel = true;
this.Result = new WebAuthenticationResult(destination);
this.Hide();
}
}
Will this be fixed in future versions? Is there any workaround for this error?
Explicitly installing the WebView2
package and specifying an alias for it does not work - any input would be appreciated. For now I will continue to use Microsoft.Graph
in version 3.*
Issue Analytics
- State:
- Created 2 years ago
- Reactions:10
- Comments:17 (3 by maintainers)
Top GitHub Comments
I found a workaround for this! Based on this stackoverflow question here.
PackageReference
toMicrosoft.Web.WebView2
. In my case I chose version1.0.864.35
because other packages I needed to reference, depended on that version.Microsoft.Web.WebView2
package in theDependencies
section of project.webivew2
After doing this the
Dependencies
andPackages
nodes within project, show up with a yellow exclamation triangle, but the project builds without error and works.The fact that this issue existed for so long without any traction is at best laughable. All while UWP Toolkit users are advised to move to the App SDK when encountering a registry bug which was marked as “won’t fix because use App SDK”…