question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

WebView2 types exist in both Microsoft.Web.WebView2.Core and Microsoft.WinUI

See original GitHub issue

I have a .NET 5 desktop app with WinUI 3 and these are some of the package references

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:open
  • Created 2 years ago
  • Reactions:10
  • Comments:17 (3 by maintainers)

github_iconTop GitHub Comments

12reactions
dahoveycommented, Nov 29, 2021

I found a workaround for this! Based on this stackoverflow question here.

  1. Add a PackageReference to Microsoft.Web.WebView2. In my case I chose version 1.0.864.35 because other packages I needed to reference, depended on that version.
  2. Select the Microsoft.Web.WebView2 package in the Dependencies section of project.
  3. Enter an alias, i.e. webivew2

After doing this the Dependencies and Packages nodes within project, show up with a yellow exclamation triangle, but the project builds without error and works.

image

4reactions
amadeo-alexcommented, Jul 21, 2023

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”…

Read more comments on GitHub >

github_iconTop Results From Across the Web

Get started with WebView2 in WinUI 3 (Windows App SDK) ...
This article covers how to set up your development tools and create an initial WebView2 app for WinUI 3 (Windows App SDK), and...
Read more >
Get started with WebView2 in WinUI 2 (UWP) apps
WebView2 enables you to host web content using the latest Microsoft Edge browser and web technology.
Read more >
How to resolve error CS0433: The type 'type' exists both in ' ...
The problem is that Microsoft.EntityFrameworkCore.SqlServer after version 7 and greater produceS this problem. Downgrading the version to ...
Read more >
Release Notes for the WebView2 SDK
WebView2 changes may require an update to the Runtime, SDK, or both. Most new APIs require both Runtime and SDK updates.
Read more >
Understand the different WebView2 SDK versions
Understand the different WebView2 SDK versions, and version models used for Microsoft Edge WebView2.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found