Reputation: 23868
I'm working on this official tutorial: Getting started with WebView2 in WPF (Preview).
Microsoft Edge (Chromium) Canary channel
on my Windows 10 pro -ver 1903
..NET Core 3.1 - WPF
project on latest version VS2019 - ver16.6.3
.But, per instructions in step 3 of the tutorial, when I add namespace xmlns:wv2="clr-namespace:Microsoft.Web.WebView2.Wpf;assembly=Microsoft.Web.WebView2.Wpf"
in <Window/>
tag of MainWindow.xaml
, and build (F5) the app, I get the following error at line using Microsoft.Web.WebView2.Wpf;
of the MainWindow.g.cs
file:
Error:
Error CS0234 The type or namespace name 'Web' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)
MainWindow.xaml:
<Window x:Class="WpfWebView2TEST.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:wv2="clr-namespace:Microsoft.Web.WebView2.Wpf;assembly=Microsoft.Web.WebView2.Wpf"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Grid>
</Grid>
</Window>
Question: What may be a cause of the error and how can it be resoled?
Upvotes: 4
Views: 8038
Reputation: 10940
To use the WebView2
control in .Net
you must use the the version, that is marked 'pre-release'.
Only that version contains the .Net librarys necessary.
It is actually mentioned (but not very clear) on the installation page.
When installing, make sure you have 'Include prerelease' checked:
Note: After you have installed the 'pre-release' version, Visual Studio
will tell you there's an update (which is the version without 'pre-release'). DO NOT UPGRADE!
Well, at some point in the future, they will of course support .Net from the standard version, but not for now.
Upvotes: 20
Reputation: 16
It's System.Web in 2019.
However, if you are trying to get to WebView Class, you need to use the Windows.UI.Xaml.Controls namspace.
I can read your code and see what your trying to do and this is what is it is fro Visual Studio 2019.
Upvotes: 0