基于 Chromium Edge 的 WebView2 不起作用
Chromium Edge-based WebView2 does not work
我已经按照 WebView2 入门(开发人员预览版(中的所有说明创建了一个使用 Microsoft Edge (Chromium( 的应用程序。但是,它无法找到 Edge 浏览器。我也尝试了示例应用程序(这个和这个(,但结果相同。我已经为 32 位和 64 位构建了应用程序。
我从调用CreateWebView2EnvironmentWithDetails()
中得到的是错误0x80070002
,这是ERROR_FILE_NOT_FOUND
(系统找不到指定的文件。
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 位(
- 视窗 10.0.17134
- Visual Studio 2019 16.4.2
知道为什么找不到我的 Edge 安装吗?
浏览器的版本可能与最新版本的SDK不兼容,您可能需要返回某些版本才能正常工作,如下列表:
https://learn.microsoft.com/en-us/microsoft-edge/hosting/webview2/releasenotes
编辑: 正如WebView2的一位开发人员所告知的那样,目前WebView2仍处于预览版本中,因此最新版本的Webview2将始终伴随着最新的Edge金丝雀版本。
https://github.com/MicrosoftEdge/WebViewFeedback/issues/103#issuecomment-575287157
我遇到了同样的错误,安装 WebView2 运行时后,它可以工作。 https://developer.microsoft.com/microsoft-edge/webview2
必须安装 WebView2 运行时才能运行兼容的应用程序。
此外,您需要升级 NuGet 包,也许在您的代码中您仍然有"预发布版本"的引用。 在该版本中,缺少"WebView2Environment",它有点像"WebView2Experiment"。
- 将边缘更新到最新版本。
- 将 Nuget WebView2 SDK 更新为最新版本(包括预发布(
- 我的神经网络不起作用 [XOR 问题]
- 在C++程序中输入的文本文件将不起作用,除非文本被复制和粘贴
- C++映射:具有自定义类的运算符[]不起作用(总是返回0)
- C++为什么尽管我调用了void函数,它却不起作用
- 为什么在保护模式下继承升级不起作用
- 循环在计数器中不起作用
- 在其他文件中创建类时在 c++ 项目中不起作用
- Visual studio代码重构似乎不起作用(例如,重命名符号-f2)
- 为什么二进制搜索在我的测试中不起作用
- 我的代码中有错误吗?使用BGI图形的C++代码对我不起作用
- 为什么 const std::p air<K,V>& 在 std::map 上基于范围的 for 循环不起作用?
- 带有指定长度字符* 参数的 std::regex_search 在 VS2017 中不起作用?
- Bjarne Stroustrup Book - std_lib_facilities.h - 不起作用(未知类型名称)
- 为什么简单的算术减法在"if"条件下不起作用?
- 为什么Stroustup书中的has_f不起作用
- 你能检查一下为什么在这个代码中从链接列表中删除项目不起作用吗
- 嵌套While循环不起作用(C++问题)
- C++Matching Brackets 2解决方案不起作用
- 为什么这段代码不起作用,我该如何解决?
- 基于 Chromium Edge 的 WebView2 不起作用