1

Why can I not use WebView2 in my .NET 8.0 WPF application?

I can load the package from NuGet, the dlls are referenced in my project:

  • Microsoft.Web.WebView2.Core
  • Microsoft.Web.WebView2.WinForms
  • Microsoft.Web.WebView2.Wpf

Those dlls are also present in the debug folder.

I added just a simple WV2 in my XAML:

<Window x:Class="webview2test.MainWindow"
 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
 xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
 xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
 xmlns:local="clr-namespace:webview2test"
 xmlns:wv2="clr-namespace:Microsoft.Web.WebView2.Wpf;assembly=Microsoft.Web.WebView2.Wpf"
 mc:Ignorable="d"
 Title="MainWindow" Height="450" Width="800">
<Grid>
 <wv2:WebView2 Name="webView" Source="https://www.microsoft.com" />
</Grid>
</Window>

I immediately get this error:

XDG0003 Unable to load the file or assembly 'Microsoft.Web.WebView2.Wpf, Version=1.0.3351.48, Culture=neutral, PublicKeyToken=2a8ab48044d2601e'

It seems wv2:WebView2 is the source of the problem...

How can I resolve this?

EDIT to add more details

I installed the WebView2 with NuGet and I can see the Microsoft.Web.WebView2 listed in the packages folder

the csproj:

<Project Sdk="Microsoft.NET.Sdk">
 <PropertyGroup>
 <OutputType>WinExe</OutputType>
 <TargetFramework>net8.0-windows</TargetFramework>
 <Nullable>enable</Nullable>
 <ImplicitUsings>enable</ImplicitUsings>
 <UseWPF>true</UseWPF>
 </PropertyGroup>
 <ItemGroup>
 <PackageReference Include="Microsoft.Web.WebView2" Version="1.0.3351.48" />
 </ItemGroup>
</Project>

EDIT more details after cleaning all project errors

The error is only appearin in a Tabitem user control but don't affect the application to work

<TabItem x:Class="WpfApp1.WebBrowser"
 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
 xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
 xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
 xmlns:local="clr-namespace:WpfApp1"
 xmlns:web="clr-namespace:Microsoft.Web.WebView2.Wpf;assembly=Microsoft.Web.WebView2.Wpf"
 mc:Ignorable="d" 
 d:DesignHeight="450" d:DesignWidth="800">
 <Grid>
 <web:WebView2 Name="Browser" Source="http://192.168.1.150"></web:WebView2>
 </Grid> 
</TabItem>

END

I didn't found any solution but at the same time that error isn't really blocking the script to run correctly, maybe a bug? Anyway I will continue like this for now and see if in the future I will get more troubles

asked Jul 11, 2025 at 13:14
3
  • How did you install the WebView2 package? Did you use NuGet Package Manager? Do you see the reference of WebView2 in Dependencies->Packages? -- Post the content of the .csproj file Commented Jul 11, 2025 at 14:39
  • XDG003 is just a designer issue. Do you have any other errors? If not, try cleaning the project, restarting, and rebuilding. Commented Jul 11, 2025 at 17:50
  • @JayBuckman Has a great point. Sometimes clearing the bin and obj folders restarting can fix some of these issues. Commented Jul 15, 2025 at 14:44

0

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.