C#开发WinForm使用CefSharp使用

 时间:2024-10-25 10:05:40

1、在C#的WinForm项目,引入了CefSharp,直接运行程序,会报错error : CefSharp.Common contains unmanaged resoures, set your project and solution platform to x86 or x64. Alternatively for AnyCPU Support see https://github.com/cefsharp/CefSharp/issues/1714

C#开发WinForm使用CefSharp使用

2、需要指定运行的平台,在解决方案右键,选择配置管理器

C#开发WinForm使用CefSharp使用

3、在活动解决方案平台选择新建,新建一个x86的平台

C#开发WinForm使用CefSharp使用

4、再次点击启动就没有报错了

C#开发WinForm使用CefSharp使用

5、在程序源代码Form1.cs引用using CefSharp;using CefSharp.WinForms;

C#开发WinForm使用CefSharp使用

6、改写程序源代码Form1.cs,如下:using System;using System.Collectio荏鱿胫协ns.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows.Forms;using CefSharp;using CefSharp.WinForms;namespace CefTest1{ public partial class Form1 : Form { public Form1() { InitializeComponent(); Cef.Initialize(new CefSettings()); ChromiumWebBrowser webBro = new ChromiumWebBrowser("https://www.baidu.com") ; this.Controls.Add(webBro); webBro.Dock = DockStyle.Fill; } }}使用CefSharp的浏览器访问百度

C#开发WinForm使用CefSharp使用

7、运行程序,网页显示在窗体中铺满

C#开发WinForm使用CefSharp使用
  • 支付宝的到位功能是什么_在哪里_怎么用详细介绍
  • 为什么相亲后在一起的人很少?
  • 天使之战手游中怎么购买角色改名卡
  • 奶奶教你做清炒墨鱼花
  • 哪个海参品牌好,怎么选?
  • 热门搜索
    小学数学手抄报图片 防灾减灾手抄报大全 关于戒烟的手抄报 以感恩为主题的手抄报 关爱生命手抄报 校园手抄报图片 数学王国手抄报 安全法制手抄报内容 有关感恩的手抄报 读书手抄报大全