uno: Desktop (Windows) : System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Web.WebView2.Wpf

Current behavior

App with WebView2 throws System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Web.WebView2.Wpf when targeting Desktop on Windows.

App's Console log

warn: Uno.UI.Runtime.Skia.Wpf.Rendering.WpfRendererProvider[0]
      OpenGL failed to initialize, using software rendering
The specified framework 'Microsoft.WindowsDesktop.App' is not present in the previously loaded runtime.
fail: Uno.UI.Dispatching.NativeDispatcher[0]
      NativeDispatcher unhandled exception
      System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Web.WebView2.Wpf, Version=1.0.2592.51, Culture=neutral, PublicKeyToken=2a8ab48044d2601e'. The system cannot find the file specified.
      File name: 'Microsoft.Web.WebView2.Wpf, Version=1.0.2592.51, Culture=neutral, PublicKeyToken=2a8ab48044d2601e'
         at Uno.UI.Runtime.Skia.Wpf.Extensions.WpfNativeWebViewProvider.CreateNativeWebView(ContentPresenter contentPresenter)
         at Microsoft.Web.WebView2.Core.CoreWebView2.GetNativeWebViewFromTemplate() in /__w/1/s/src/Uno.UI/UI/Xaml/Controls/WebView/Core/CoreWebView2.skia.cs:line 22
         at Microsoft.Web.WebView2.Core.CoreWebView2.OnOwnerApplyTemplate() in /__w/1/s/src/Uno.UI/UI/Xaml/Controls/WebView/Core/CoreWebView2.cs:line 156
         at Microsoft.UI.Xaml.Controls.WebView2.OnApplyTemplate() in /__w/1/s/src/Uno.UI/UI/Xaml/Controls/WebView/WebView2/WebView2.cs:line 49
         at Microsoft.UI.Xaml.FrameworkElement.InvokeApplyTemplate(Boolean& addedVisuals) in /__w/1/s/src/Uno.UI/UI/Xaml/FrameworkElement.Layout.crossruntime.cs:line 240
         at Microsoft.UI.Xaml.FrameworkElement.InnerMeasureCore(Size availableSize) in /__w/1/s/src/Uno.UI/UI/Xaml/FrameworkElement.Layout.crossruntime.cs:line 286
         at Microsoft.UI.Xaml.FrameworkElement.MeasureCore(Size availableSize) in /__w/1/s/src/Uno.UI/UI/Xaml/FrameworkElement.Layout.crossruntime.cs:line 160
         at Microsoft.UI.Xaml.UIElement.Measure(Size availableSize) in /__w/1/s/src/Uno.UI/UI/Xaml/UIElement.Layout.crossruntime.cs:line 170
         at Microsoft.UI.Xaml.FrameworkElement.MeasureElement(UIElement view, Size availableSize) in /__w/1/s/src/Uno.UI/UI/Xaml/FrameworkElement.cs:line 390
         at Microsoft.UI.Xaml.Controls.Grid.MeasureCell(UIElement child, CellUnitTypes rowHeightTypes, CellUnitTypes columnWidthTypes, Boolean forceRowToInfinity, Double rowSpacing, Double columnSpacing) in /__w/1/s/src/Uno.UI/UI/Xaml/Controls/Grid/Grid.cs:line 498
         at Microsoft.UI.Xaml.Controls.Grid.MeasureCellsGroup(Int32 cellsHead, Int32 cellCount, Double rowSpacing, Double columnSpacing, Boolean ignoreColumnDesiredSize, Boolean forceRowToInfinity, CellCacheStackVector& cellCacheVector) in /__w/1/s/src/Uno.UI/UI/Xaml/Controls/Grid/Grid.cs:line 373
         at Microsoft.UI.Xaml.Controls.Grid.MeasureOverride(Size availableSize) in /__w/1/s/src/Uno.UI/UI/Xaml/Controls/Grid/Grid.cs:line 1043
         at Microsoft.UI.Xaml.FrameworkElement.InnerMeasureCore(Size availableSize) in /__w/1/s/src/Uno.UI/UI/Xaml/FrameworkElement.Layout.crossruntime.cs:line 327
         at Microsoft.UI.Xaml.FrameworkElement.MeasureCore(Size availableSize) in /__w/1/s/src/Uno.UI/UI/Xaml/FrameworkElement.Layout.crossruntime.cs:line 160
         at Microsoft.UI.Xaml.UIElement.Measure(Size availableSize) in /__w/1/s/src/Uno.UI/UI/Xaml/UIElement.Layout.crossruntime.cs:line 170
         at Microsoft.UI.Xaml.FrameworkElement.MeasureElement(UIElement view, Size availableSize) in /__w/1/s/src/Uno.UI/UI/Xaml/FrameworkElement.cs:line 390
         at Microsoft.UI.Xaml.Controls.Control.MeasureOverride(Size availableSize) in /__w/1/s/src/Uno.UI/UI/Xaml/Controls/Control/Control.cs:line 463
         at Microsoft.UI.Xaml.Controls.ContentControl.MeasureOverride(Size availableSize) in /__w/1/s/src/Uno.UI/UI/Xaml/Controls/ContentControl/ContentControl.skia.cs:line 28
         at Microsoft.UI.Xaml.FrameworkElement.InnerMeasureCore(Size availableSize) in /__w/1/s/src/Uno.UI/UI/Xaml/FrameworkElement.Layout.crossruntime.cs:line 327
         at Microsoft.UI.Xaml.FrameworkElement.MeasureCore(Size availableSize) in /__w/1/s/src/Uno.UI/UI/Xaml/FrameworkElement.Layout.crossruntime.cs:line 160
         at Microsoft.UI.Xaml.UIElement.Measure(Size availableSize) in /__w/1/s/src/Uno.UI/UI/Xaml/UIElement.Layout.crossruntime.cs:line 170
         at Microsoft.UI.Xaml.FrameworkElement.MeasureElement(UIElement view, Size availableSize) in /__w/1/s/src/Uno.UI/UI/Xaml/FrameworkElement.cs:line 390
         at Microsoft.UI.Xaml.Controls.ContentPresenter.MeasureOverride(Size size) in /__w/1/s/src/Uno.UI/UI/Xaml/Controls/ContentPresenter/ContentPresenter.cs:line 1287
         at Microsoft.UI.Xaml.FrameworkElement.InnerMeasureCore(Size availableSize) in /__w/1/s/src/Uno.UI/UI/Xaml/FrameworkElement.Layout.crossruntime.cs:line 327
         at Microsoft.UI.Xaml.FrameworkElement.MeasureCore(Size availableSize) in /__w/1/s/src/Uno.UI/UI/Xaml/FrameworkElement.Layout.crossruntime.cs:line 160
         at Microsoft.UI.Xaml.UIElement.Measure(Size availableSize) in /__w/1/s/src/Uno.UI/UI/Xaml/UIElement.Layout.crossruntime.cs:line 170
         at Microsoft.UI.Xaml.FrameworkElement.MeasureElement(UIElement view, Size availableSize) in /__w/1/s/src/Uno.UI/UI/Xaml/FrameworkElement.cs:line 390
         at Microsoft.UI.Xaml.Controls.Control.MeasureOverride(Size availableSize) in /__w/1/s/src/Uno.UI/UI/Xaml/Controls/Control/Control.cs:line 463
         at Microsoft.UI.Xaml.Controls.ContentControl.MeasureOverride(Size availableSize) in /__w/1/s/src/Uno.UI/UI/Xaml/Controls/ContentControl/ContentControl.skia.cs:line 28
         at Microsoft.UI.Xaml.FrameworkElement.InnerMeasureCore(Size availableSize) in /__w/1/s/src/Uno.UI/UI/Xaml/FrameworkElement.Layout.crossruntime.cs:line 327
         at Microsoft.UI.Xaml.FrameworkElement.MeasureCore(Size availableSize) in /__w/1/s/src/Uno.UI/UI/Xaml/FrameworkElement.Layout.crossruntime.cs:line 160
         at Microsoft.UI.Xaml.UIElement.Measure(Size availableSize) in /__w/1/s/src/Uno.UI/UI/Xaml/UIElement.Layout.crossruntime.cs:line 170
         at Uno.UI.Xaml.Core.RootVisual.MeasureOverride(Size availableSize) in /__w/1/s/src/Uno.UI/UI/Xaml/Internal/RootVisual.cs:line 69
         at Microsoft.UI.Xaml.FrameworkElement.InnerMeasureCore(Size availableSize) in /__w/1/s/src/Uno.UI/UI/Xaml/FrameworkElement.Layout.crossruntime.cs:line 327
         at Microsoft.UI.Xaml.FrameworkElement.MeasureCore(Size availableSize) in /__w/1/s/src/Uno.UI/UI/Xaml/FrameworkElement.Layout.crossruntime.cs:line 160
         at Microsoft.UI.Xaml.UIElement.Measure(Size availableSize) in /__w/1/s/src/Uno.UI/UI/Xaml/UIElement.Layout.crossruntime.cs:line 165
         at Microsoft.UI.Xaml.UIElement.UpdateLayout() in /__w/1/s/src/Uno.UI/UI/Xaml/UIElement.cs:line 782
         at Uno.UI.Xaml.Core.CoreServices.OnTick() in /__w/1/s/src/Uno.UI/UI/Xaml/Internal/CoreServices.cs:line 102
         at Uno.UI.Xaml.Core.CoreServices.<>c.<RequestAdditionalFrame>b__9_0() in /__w/1/s/src/Uno.UI/UI/Xaml/Internal/CoreServices.cs:line 60
         at Uno.UI.Dispatching.NativeDispatcher.RunAction(NativeDispatcher dispatcher, Action action) in /__w/1/s/src/Uno.UI.Dispatching/Native/NativeDispatcher.cs:line 148

Expected behavior

WebView2 loads correctly.

How to reproduce it (as minimally and precisely as possible)

Tap [LOAD CONTENT] button in the UnoWebView2Test solution, found in the following repo:

Workaround

None known

Works on UWP/WinUI

Yes

Environment

Uno.WinUI / Uno.WinUI.WebAssembly / Uno.WinUI.Skia

NuGet package version(s)

Uno.Sdk 5.6.51

Affected platforms

Skia (WPF)

IDE

Visual Studio 2022

IDE version

Microsoft Visual Studio Community 2022 (ARM 64-bit) - Current Version 17.13.5

Relevant plugins

VisualStudio Environment

Microsoft Visual Studio Community 2022 Version 17.13.5 VisualStudio.17.Release/17.13.5+35919.96 Microsoft .NET Framework Version 4.8.09032

Installed Version: Community

Visual C++ 2022 00482-90000-00000-AA155 Microsoft Visual C++ 2022

ASP.NET and Web Tools 17.13.124.35287 ASP.NET and Web Tools

AvaloniaPackage Extension 1.0 AvaloniaPackage Visual Studio Extension Detailed Info

Azure App Service Tools v3.0.0 17.13.124.35287 Azure App Service Tools v3.0.0

Azure Functions and Web Jobs Tools 17.13.124.35287 Azure Functions and Web Jobs Tools

C# Tools 4.13.0-3.25167.3+73eff2b5de2ad38ec602c0a9e82f9125fb85992b C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

GitHub Copilot 17.13.441.19478 GitHub Copilot is an AI pair programmer that helps you write code faster and with less work.

ILSpy.AddIn 1.0 Integration of the ILSpy Decompiler into Visual Studio.

Microsoft JVM Debugger 1.0 Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines

Node.js Tools 1.5.61125.7 Commit Hash:d387982a7546304d617ed77b6d390e04b6558274 Adds support for developing and debugging Node.js apps in Visual Studio

NuGet Package Manager 6.13.2 NuGet Package Manager in Visual Studio. For more information about NuGet, visit https://docs.nuget.org/

Razor (ASP.NET Core) 17.13.3.2512306+41f62d0b8021cafc33bdefdb7e0198c8d2eb59ac Provides languages services for ASP.NET Core Razor.

SQL Server Data Tools 17.13.3.1 Microsoft SQL Server Data Tools

TypeScript Tools 17.0.31211.2001 TypeScript Tools for Microsoft Visual Studio

Uno Platform Extension 1.0 Uno Platform Extension to create cross-platform apps using iOS, Android, mac Catalyst, Skia and WebAssembly.

Visual Basic Tools 4.13.0-3.25167.3+73eff2b5de2ad38ec602c0a9e82f9125fb85992b Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Visual F# Tools 17.13.0-beta.25154.2+82a3f54f7140a62e6398403451098c4517747c02 Microsoft Visual F# Tools

Visual Studio IntelliCode 2.2 AI-assisted development for Visual Studio.

VisualStudio.DeviceLog 1.0 Information about my package

VisualStudio.Mac 1.0 Mac Extension for Visual Studio

VSPackage Extension 1.0 VSPackage Visual Studio Extension Detailed Info

Xamarin 17.13.0.175 (d17.13@ab30e87) Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin Designer 17.13.3.4 (remotes/origin/main@59e9def289) Visual Studio extension to enable Xamarin Designer tools in Visual Studio.

Xamarin.Android SDK 13.2.2.0 (d17-5/45b0e14) Xamarin.Android Reference Assemblies and MSBuild support. Mono: d9a6e87 Java.Interop: xamarin/java.interop/d17-5@149d70fe SQLite: xamarin/sqlite/3.40.1@68c69d8 Xamarin.Android Tools: xamarin/xamarin-android-tools/d17-5@ca1552d

Xamarin.iOS and Xamarin.Mac SDK 16.4.0.23 (9defd91b3) Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.

System Info

OS Name Microsoft Windows 11 Enterprise Version 10.0.22631 Build 22631 Other OS Description Not Available OS Manufacturer Microsoft Corporation System Name BENJAMINASK9DB7 System Manufacturer Parallels International GmbH. System Model Parallels ARM Virtual Machine System Type ARM64-based PC System SKU Parallels_ARM_VM Processor Apple Silicon, 3200 Mhz, 1 Core(s), 1 Logical Processor(s) Processor Apple Silicon, 3200 Mhz, 1 Core(s), 1 Logical Processor(s) Processor Apple Silicon, 3200 Mhz, 1 Core(s), 1 Logical Processor(s) Processor Apple Silicon, 3200 Mhz, 1 Core(s), 1 Logical Processor(s) Processor Apple Silicon, 3200 Mhz, 1 Core(s), 1 Logical Processor(s) Processor Apple Silicon, 3200 Mhz, 1 Core(s), 1 Logical Processor(s) BIOS Version/Date Parallels International GmbH. 20.2.2 (55879), Not Available SMBIOS Version 3.0 Embedded Controller Version 255.255 BIOS Mode UEFI BaseBoard Manufacturer Parallels ARM Virtual Machine BaseBoard Product Parallels ARM Virtual Platform BaseBoard Version 0.1 Platform Role Slate Secure Boot State On PCR7 Configuration Elevation Required to View Windows Directory C:\Windows System Directory C:\Windows\system32 Boot Device \Device\HarddiskVolume2 Locale United States Hardware Abstraction Layer Version = “10.0.22621.2506” User Name BENJAMINASK9DB7\ben Time Zone SA Western Standard Time Installed Physical Memory (RAM) 48.0 GB Total Physical Memory 40.0 GB Available Physical Memory 27.7 GB Total Virtual Memory 42.5 GB Available Virtual Memory 30.3 GB Page File Space 2.50 GB Page File C:\pagefile.sys Kernel DMA Protection Off Virtualization-based security Not enabled Windows Defender Application Control policy Enforced Windows Defender Application Control user mode policy Off Device Encryption Support Elevation Required to View A hypervisor has been detected. Features required for Hyper-V will not be displayed.

Anything else we need to know?

No response

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 16 (16 by maintainers)

Most upvoted comments

Thanks, @jeromelaban . Fix verified.

@baskren you’ll need to create a new project with the updated program.cs with includes [STAThread].

Thanks, the error you’re getting for this is related to the missing attribute in the app’s entry point, we’re fixing this with a very soon coming update. https://github.com/unoplatform/uno.templates/pull/1475