基于Chromium Edge的WebView2不起作用 [英] Chromium Edge-based WebView2 does not work

查看:202
本文介绍了基于Chromium Edge的WebView2不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经按照 WebView2入门(开发人员预览),以创建使用Microsoft Edge(Chromium)的应用.但是,它无法找到Edge浏览器.我还尝试了示例应用程序(

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.

我从调用 CreateWebView2EnvironmentWithDetails()得到的是错误 0x80070002 ,它是 ERROR_FILE_NOT_FOUND (系统找不到指定的文件.)

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);
  }
}

我有:

  • Edge版本79.0.309.60(正式版本)测试版(64位)
  • Windows 10.0.17134
  • Visual Studio 2019 16.4.2

为什么找不到我的Edge安装程序?

Any ideas why my Edge installation is not found?

推荐答案

浏览器的版本可能与最新版本的SDK不兼容,您可能必须返回一些版本才能使其正常工作,请按照以下列表操作:

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

正如WebView2的一位开发人员所告知的那样,目前WebView2仍处于预览版本,因此始终将最新版本的Webview2与最新的Canary版本的Edge一起使用.

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

这篇关于基于Chromium Edge的WebView2不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆