

WebView2简单试用(四)—— 使用固定版本的Edge Runtime
source link: https://www.cnblogs.com/TianFang/p/14354812.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Edge Runtime支持两种模式:长绿(All Green)和固定版本(Fixed Version)这两种方式和vc runtime安装比较类似。 长绿版本可以作为独立的安装包安装,所有程序共享。固定版本则也可以直接在程序中包含。
长绿版本的优势:
-
可以自动更新
-
支持在线和离线安装
-
所有WebView2程序共享运行时,节约磁盘空间
固定版本的优势:
-
可防止版本升级到来的兼容性问题
-
可防止运行时被意外卸载
-
可和应用程序集成在一起
之前都是使用的All Green模式,本文这里介绍下Fixed Version模式的集成方法。
下载Runtime
- 打开Edge WebView Runtime下载页面,下载下载固定版本(Fixed Version),可以选择不同的版本和cpu架构。下载后,会得到一个几十兆的cab文件
- 解压cab文件至指定文件夹:expand xxxxx.cab -f:* r:\webview2
配置WebView
初始化程序的时候,指定该路径:(WPF示例)
var env = await CoreWebView2Environment.CreateAsync(@"R:\WebView2");
await webView.EnsureCoreWebView2Async(env);
通过这种方式,可以把runtime和应用程序集成在一起。不过,这种模式下,某些API使用会出问题,如: CoreWebView2.Environment.BrowserVersionString(不知道是否是bug)。
参考文档:
Recommend
-
18
WebView2简单试用(九)—— Dev Protocol 有的时候,我们需要实现一些更为高级的操作,以提供更个性化的功能。常用的注入...
-
9
WebView2简单试用(七)—— WebMessage 之前文章中介...
-
10
WebView2简单试用(六)—— 常用设置 初始化时设置 WebView2的初始化方式如下: var env = await Co...
-
4
WebView2简单试用(二)—— 基本操作 前文中简单的介...
-
18
WebView2简单试用(五)—— 自定义用户数据文件夹 默认情况下,WebView2程序的用户数据是按程序独立存储的:
-
12
WebView2简单试用(三)—— 新窗口打开页面的处理 当我们进行页面跳转的时候,有的时候回使用新窗口打开,WebView2会弹出...
-
27
WebView2简单试用(一)—— 开始 WebView2控件现在已经正式发布了,准备写一系列文章简单的介绍下,本文简单的先介绍下安...
-
8
WebView2简单试用(八)—— 右键菜单 默认菜单: WebView2本身携带了类似Edge的右键菜单,但有的时候我们需要对...
-
6
WebView2 Windows App SDK, WinUI2, Runtime, and CDP Helper Updates Written By published...
-
11
Delivering the Microsoft Edge WebView2 Runtime to Windows 10 Consumers Written By pub...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK