Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I add WebView2 control in Visual Studio Toolbar?

In Visual Studio 2019, using Nuget, I have installed Microsoft.Web.WebView2 package.

PM> Install-Package Microsoft.Web.WebView2 -Version 0.9.430

As explained on Web, I have installed new Microsoft Edge Chromium Canary version (it is important).

Now, when I open the Toolbox, I don't see any WebView2 control.

Before that, I have installed WebView control (old version that is working with old Edge browser).

After installing WebView, the control has been visible immediately in Toolbox.

But this is not the case with WebView2 control.

I have tried to add in Toolbox all controls from Microsoft.Web.WebView2 package manually.

But Visual Studio refuses to load WebView2Loader.dll found in following folder

C:\Users\bernard\.nuget\packages\microsoft.web.webview2\0.9.430\build\x86

I have also tried with DLL found in

C:\Users\bernard\.nuget\packages\microsoft.web.webview2\0.9.430\build\x64

Is there possible to install WebView2 control in Toolbox ?

If yes, how ?

like image 570
schlebe Avatar asked Apr 18 '20 15:04

schlebe


People also ask

How do I enable WebView2?

Then, go to Customization > Device Configuration > Modern Apps Settings. Select Microsoft Edge WebView2 and then clear the Enable automatic installation of WebView2 Runtime check box.

What is WebView2 control?

The Microsoft Edge WebView2 control allows you to embed web technologies (HTML, CSS, and JavaScript) in your native apps. The WebView2 control uses Microsoft Edge as the rendering engine to display the web content in native apps.

What is WebView in C#?

The WebView control shows web content in your Windows Forms or WPF desktop application. This is one of several wrapped Universal Windows Platform controls that are available for Windows Forms and WPF applications. For more information, see UWP controls in desktop applications.

What is WebView2Loader DLL?

WebView2Loader. dll is a small component that helps apps locate the WebView2 Runtime, or Microsoft Edge preview channels, on the device.


1 Answers

I also had this problem. I followed the instructions in the Getting Started tutorial:

https://docs.microsoft.com/en-us/microsoft-edge/webview2/gettingstarted/winforms

and installed Canary Edge as well, but the controls were still not appearing. However, it is interesting that the Microsoft.Web.WebView2.WinForms references were not showing up in the References of my Windows Form project initially. They are now appearing, but it is not clear why any of the following steps were necessary after initially simply using Nuget to installing Canary and the latest version of the WebView2 control.

  1. After reinstalling Canary, restart Windows
  2. Clean Project
  3. In Manage Nuget packages, reinstall the WebView2 package to a lower version (I used the prelease of the current version, 0.9.538-prerelease)

After the third step, the library references to the WebView2 control appeared in my project References for the first time, and I was able to use them in the Form Designer.

NOTE: trying to update the control to the release version on 0.9.538 caused the references to disappear from the References and the WebView2 control was no longer available to the Form Designer. Reinstalling the prerelease solved the issue, so it appears the release of 0.9.538 supports a smaller scope than its prerelease.

TL;DR: do not update to the latest version of 0.9.538, just use the 0.9.538-prerelease.

like image 56
longestwayround Avatar answered Oct 14 '22 06:10

longestwayround