How can I use the Microsoft Edge WebView2 control in C# windows application using Visual Studio?
-
If you want to get started with webview2, I have a simple c# WPF example on GitHub that can be helpful: https://github.com/GrooverFromHolland/WebView2_YoutubeBackingTracks/tree/master/YoutubeBackingTracks – GrooverFromHolland Jul 20 '21 at 19:32
3 Answers
Now in 2020 WebView2 supports both WPF and WinForms so you can try to use it in your application.
https://learn.microsoft.com/en-us/microsoft-edge/webview2/
https://learn.microsoft.com/en-us/microsoft-edge/webview2/gettingstarted/wpf
Basically you need to add Nuget package Microsoft.Web.WebView2 and then use WebView2 control.

- 5,613
- 12
- 49
- 68
-
7Don't forget to install the correct version of Edge. Currently (May 22, 2020) that is 84.xxxxxxx. The how to documentation doesn't call this out nearly clear enough. Nor is there error checking for the correct version. (NullReferenceException if the correct version of Edge is not on your machine) – Brad Bruce May 22 '20 at 11:57
-
@BradBruce What if you only have the version that comes with Windows Update? The API will be pretty useless if incompatible with Microsoft pushed versions... – l33t Aug 12 '20 at 10:53
-
1Added the nuget package, but WebView2 does not appear in the toolbox? (vs 2019) – Thomas Harris Aug 22 '20 at 12:20
The Microsoft Edge WebView2 (powered by Microsoft Edge (Chromium) as the rendering engine) is available on the following programming environments: Win32 C/C++ (GA), .NET Framework 4.6.2 or later, .NET Core 3.1 or later and .NET 5.
Get started with WebView2
Install prerequisites on your machine:
Create a Windows Forms Application.
Install WebView2 NuGet package in your project.
Drop an instance of the WebView2 from toolbox on your form.
Set the Source property to a valid URL like: https://example.com and run the application.
More information

- 120,393
- 18
- 203
- 398
You cannot currently do it without some hacks as it is missing the interfaces. It only support C++ win32 API for the time being. Please see this post for more information https://github.com/MicrosoftEdge/WebViewFeedback/issues/46

- 21
- 2
-
6Please note that this is NO LONGER the case. .NET/C# now has a very good NuGet package that allows most of the functionality available in the C++ version. The issue you highlight in your answer is now closed and many of us have now been using WebView2 easily in our .NET windows forms projects. – shawty Jun 10 '20 at 11:32