Home > Net >  Errors in creating a Webview2 sample app in UWP
Errors in creating a Webview2 sample app in UWP

Time:08-11

I am following the steps mentioned enter image description here

and upon building I encounter a lot of errors like

error C3083: 'Microsoft': the symbol to the left of a '::' must be a type (compiling source file MainPage.cpp)
error C3083: 'UI': the symbol to the left of a '::' must be a type (compiling source file MainPage.cpp)
error C3083: 'Xaml': the symbol to the left of a '::' must be a type (compiling source file MainPage.cpp)
error C3083: 'Controls': the symbol to the left of a '::' must be a type (compiling source file MainPage.cpp)
error C3646: 'WebView2': unknown override specifier (compiling source file MainPage.cpp)

essentially complaining about the usage of Microsoft in ::winrt::Microsoft::UI::Xaml::Controls::WebView2

I'm not sure what's exactly going wrong and can't find something similar to my issue. Would anybody know what's missing/needs to be changed to get the sample working?

CodePudding user response:

Errors in creating a Webview2 sample app in UWP

As Raymond Chen points out the code is failing to include the C /WinRT projection headers for Microsoft::UI::Xaml::Controls. After installing the NuGet package, please go to pch.h and add the following #include directives. For more info you could refer to A basic C /WinRT Windows UI Library 2 example (UWP) document.

#include "winrt/Microsoft.UI.Xaml.Automation.Peers.h"
#include "winrt/Microsoft.UI.Xaml.Controls.h"
#include "winrt/Microsoft.UI.Xaml.Controls.Primitives.h"
#include "winrt/Microsoft.UI.Xaml.Media.h"
#include "winrt/Microsoft.UI.Xaml.XamlTypeInfo.h"
  • Related