Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chromium Edge-based WebView2 does not work

I have followed all the instructions from Getting Started with WebView2 (developer preview) to create an app that is using Microsoft Edge (Chromium). However, it is not able to find the Edge browser. I also tried the sample apps (this and this) but with the same results. I have built the apps both for 32- and 64-bit.

What I get from calling CreateWebView2EnvironmentWithDetails() is error 0x80070002, which is ERROR_FILE_NOT_FOUND (The system cannot find the file specified.)

HRESULT hr = CreateWebView2EnvironmentWithDetails(nullptr, nullptr, nullptr,
  Callback<IWebView2CreateWebView2EnvironmentCompletedHandler>(
     [hWnd](HRESULT result, IWebView2Environment* env) -> HRESULT {

        // Create a WebView, whose parent is the main window hWnd
        env->CreateWebView(hWnd, Callback<IWebView2CreateWebViewCompletedHandler>(
           [hWnd](HRESULT result, IWebView2WebView* webview) -> HRESULT {
              if (webview != nullptr) {
                 webviewWindow = webview;
              }

              // Resize WebView to fit the bounds of the parent window
              RECT bounds;
              GetClientRect(hWnd, &bounds);
              webviewWindow->put_Bounds(bounds);

              // Schedule an async task to navigate to Bing
              webviewWindow->Navigate(L"https://www.bing.com/");

              return S_OK;
           }).Get());
        return S_OK;
     }).Get());

if (!SUCCEEDED(hr))
{
  if (hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND))
  {
     MessageBox(
        nullptr,
        L"Couldn't find Edge installation. "
        "Do you have a version installed that's compatible with this "
        "WebView2 SDK version?",
        nullptr, MB_OK);
  }
  else
  {
     std::wstringstream formattedMessage;
     formattedMessage << L"Failed to create webview environment" 
                      << ": 0x" << std::hex << std::setw(8) << hr;
     MessageBox(nullptr, formattedMessage.str().c_str(), nullptr, MB_OK);
  }
}

I have:

  • Edge Version 79.0.309.60 (Official build) beta (64-bit)
  • Windows 10.0.17134
  • Visual Studio 2019 16.4.2

Any ideas why my Edge installation is not found?

like image 219
Marius Bancila Avatar asked Jan 13 '20 06:01

Marius Bancila


People also ask

How do I enable Microsoft Edge in 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.

How do I install WebView2 fixed?

To install WebView2 Runtime, go to the Microsoft web page Download the WebView2 Runtime (https://developer.microsoft.com/en-us/microsoft-edge/webview2/#download-section). Under Evergreen Standalone Installer, click the x64 download button. Important: You must download the 64-bit version of the installer.

Is it OK to uninstall Microsoft Edge WebView2 runtime?

I use Microsoft Edge version 104. Once it got updated, I noticed I was running out of disk space, and then I saw it was MS Edge WebView Runtime2. It doesn't show up its original size via classic control panel and UWP Settings App, and it can be uninstalled and modified.

Is WebView2 installed on Windows 10?

Microsoft says that the WebView2 runtime is already installed on more than 400 million Windows 10 PCs. The latest update now allows developers to reduce the cost of including relevant dependencies in their apps.


1 Answers

Probably the version of the Browser is not compatible with the latest version of the SDK, you may have to go back some versions for it to work, following the list:

https://docs.microsoft.com/en-us/microsoft-edge/hosting/webview2/releasenotes

Edit: As informed by one of the developers of WebView2, at the moment WebView2 is still in preview version so always the latest version of Webview2 will accompany the latest canary version of Edge.

https://github.com/MicrosoftEdge/WebViewFeedback/issues/103#issuecomment-575287157

like image 71
Fernando Vellozo Avatar answered Sep 19 '22 13:09

Fernando Vellozo