MicrosoftEdge / MicrosoftEdge/WebView2Feedback

Type identity CoreWebView2 types is different between WinUI 3 and WPF/WinForms

Open
#1,193 5 comments 0 reactions 1 assignee View on GitHub

@david-risney is already working on this.

Since Apr 16, 2021.

feature request tracked
Dominant language
PowerShell
Stars
526
Forks
67
PR merge metrics
No merged PRs in 30d

Description

Description

I'm trying to share code across all my usage of WebView2 as much as possible. Of course the controls for WinUI, WPF, and WinForms are all different, because each UI framework is different. But even seemingly platform-independent types, such as CoreWebView2 have different identities. This makes it impossible to build a class library targetting CoreWebView2 and run on all platforms.

CoreWebView2 in WinUI 3 has this identity:

  • Type name: Microsoft.Web.WebView2.Core.CoreWebView2 (same)
  • Assembly: Microsoft.WinUI, Version=3.0.0.0, Culture=neutral, PublicKeyToken=de31ebe4ad15742b (different)

CoreWebView2 in WPF/WinForms has this identity:

  • Type name: Microsoft.Web.WebView2.Core.CoreWebView2 (same)
  • Assembly: Microsoft.Web.WebView2.Core, Version=1.0.705.50, Culture=neutral, PublicKeyToken=2a8ab48044d2601e (different)
  • NuGet package version: 1.0.705.50

Version
SDK: NuGet 1.0.705.50
Runtime: N/A
Framework: WPF/WinForms and WinUI
OS: N/A

Repro Steps

  1. Build a class library that uses CoreWebView2 from the WebView2 NuGet package for WPF/Winforms.
  2. Try to have that class library also support the WinUI CoreWebView2

Result: You can't, because the type identities are different.
Expected: The type identities of platform-independent types should be identical.

Additional context

We encountered this while working on Blazor Desktop, where we support hosting Blazor directly in WPF and WinForms, and also in WinUI (via .NET MAUI). We wanted to put most of our code in a common WebView2-aware library, and then only write thin adapters to wire it up to each UI platform. However, this is not possible because the type identities are different, so we have to duplicate all the code.

AB#33281317

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.