Recent versions of Microsoft.Web.WebView2 have been designed with an unconventional structure that's incompatible with LINQPad.
However, LINQPad 8.9.2 (in beta at April 2025) includes code to special-case this package so that it works correctly. You can use both the WPF and Windows Forms WebView2 controls, although I actually find the WinForms version to be more stable:
var uri = new Uri ("http://www.linqpad.net");
PanelManager.DisplayWpfElement (
new Microsoft.Web.WebView2.Wpf.WebView2 { Source = uri });
PanelManager.DisplayControl (
new Microsoft.Web.WebView2.WinForms.WebView2 { Source = uri });
This relies on WebView2 being installed on your machine. If you would like it to work even if WebView2 is uninstalled, you can request LINQPad's version of WebView2 as follows:
var uri = new Uri ("http://www.linqpad.net");
var env = await Microsoft.Web.WebView2.Core.CoreWebView2Environment.CreateAsync (
Util.BrowserEngine.GetWebView2ExecutableFolder (),
Util.BrowserEngine.GetWebView2DataFolder ()
);
var webView2 = new Microsoft.Web.WebView2.WinForms.WebView2();
await webView2.EnsureCoreWebView2Async (env);
webView2.Source = uri;
PanelManager.DisplayControl (webView2);
1.0.2592.51NuGet package. If you have issues with theWebView2Loader.dll, call the staticCoreWebView2Environment.SetLoaderDllFolderPath()method (see the docs about it), specifying the path to the dll (not the dll file itself). Also, set the data folder, so it can be written to -- If you use the WPF version, add it to a Window + DockPanel or usePanelManager.DisplayWpfElement (yourBrowserInstance). If you use the WinForms one, just add it to a Form and set its Size (or dock it). In either case, don't just.Dump()the Control's instance