本文介绍了如何在 Visual Studio 工具栏中添加 WebView2 控件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Visual Studio 2019 中,使用 Nuget,我已经安装了 Microsoft.Web.WebView2 包.

PM>安装包 Microsoft.Web.WebView2 -Version 0.9.430

如 Web 上所述,我已经安装了新的 Microsoft Edge Chromium Canary 版本(这很重要).

现在,当我打开工具箱时,我看不到任何 WebView2 控件.

在此之前,我已经安装了 WebView 控件(使用旧版 Edge 浏览器的旧版本).

安装WebView后,该控件在Toolbox中立即可见.

但是 WebView2 控件不是这种情况.

我尝试将 Microsoft.Web.WebView2 包中的所有控件手动添加到工具箱中.

但 Visual Studio 拒绝加载在以下文件夹中找到的 WebView2Loader.dll

C:\Users\bernard\.nuget\packages\microsoft.web.webview2\0.9.430\build\x86

我也尝试过在

中找到的 DLL

C:\Users\bernard\.nuget\packages\microsoft.web.webview2\0.9.430\build\x64

是否可以在 Toolbox 中安装 WebView2 控件?

如果是,如何?

解决方案

根据

但官方的 Edge 版本是(当天)84.0.522.

所以答案是:

  • 将 Edge 更新为

    重要提示: 请勿降级! 卸载 WebView2 Nuget 包,重启 VS,安装旧版本,安全起见一边.

    In Visual Studio 2019, using Nuget, I have installed Microsoft.Web.WebView2 package.

    PM> Install-Package Microsoft.Web.WebView2 -Version 0.9.430
    

    As explained on Web, I have installed new Microsoft Edge Chromium Canary version (it is important).

    Now, when I open the Toolbox, I don't see any WebView2 control.

    Before that, I have installed WebView control (old version that is working with old Edge browser).

    After installing WebView, the control has been visible immediately in Toolbox.

    But this is not the case with WebView2 control.

    I have tried to add in Toolbox all controls from Microsoft.Web.WebView2 package manually.

    But Visual Studio refuses to load WebView2Loader.dll found in following folder

    C:\Users\bernard\.nuget\packages\microsoft.web.webview2\0.9.430\build\x86
    

    I have also tried with DLL found in

    C:\Users\bernard\.nuget\packages\microsoft.web.webview2\0.9.430\build\x64
    

    Is there possible to install WebView2 control in Toolbox ?

    If yes, how ?

    解决方案

    EDIT: According to this post you need to use Canary or Dev build of Edge or the Edge WebView2 Preview no matter what version is supposed to work according to the release notes.

    The main reason people have this problem is because they have not installed the required version of Edge.

    Check the release notes. For each release you see the "minimum Microsoft Edge version". For example, when you install the latest WebView2 release 0.9.579 (released 07/20/2020) it requires Edge 86.0.579.0

    but the official Edge build is (on that day) 84.0.522.

    So the answer is:

    Important: Do not downgrade! Uninstall WebView2 Nuget package, restart VS, install an older version of it, to be on the safe side.

    这篇关于如何在 Visual Studio 工具栏中添加 WebView2 控件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-03 23:21