WinForm使用CefSharp内嵌chrome浏览器

1.创建winform程序,使用.NET 4.5.2或以上(vs2010最高支持.NET 4.0,我使用的是vs2017)。

 

2.在解决方案上右键->"属性"->"生成"->"目标平台",选择x86或x64,Cef暂不支持"Any CPU"

 

3.下载并解压CefSharp编译好的文件,注意是32位还是64位。

CefSharp v51 x86 (for 32-bit apps)

CefSharp v51 x64 (for 64-bit apps)

 

4.将下载下来的文件解压,然后全部复制到程序bin\Debug目录 或者 bin\Release目录

 

5.项目右键"添加引用",找到下面三个文件,然后添加引用到项目。

CefSharp.dll
CefSharp.Core.dll

CefSharp.WinForms.dll

 

6.编写测试代码:

using CefSharp;
using CefSharp.WinForms;      
 
public ChromiumWebBrowser browser;
public void InitBrowser(){
    Cef.Initialize(new CefSettings());
    browser = new ChromiumWebBrowser ("www.baidu.com");
    this.Controls.Add(browser);
    browser.Dock = DockStyle.Fill;

}

在InitializeComponent()方法中调用 InitBrowser()。

7.F5调试运行即可。

 

本人内容补充

CefSharp官网: https://github.com/cefsharp/CefSharp

Cef版本、VC++版本、.Net版本对照表

Release Branches

With each release a new branch is created, for example the 73.1.130 release corresponds to the cefsharp/73 branch. If you're new to CefSharp and are downloading the source to check it out, please use a Release branch

BranchCEF VersionVC++ Version.Net VersionStatus
master394520154.5.2Development
cefsharp/79394520154.5.2Pre-Release
cefsharp/77386520154.5.2Unsupported
cefsharp/75377020154.5.2Release
cefsharp/73368320154.5.2Unsupported
cefsharp/71357820154.5.2Unsupported
cefsharp/69349720154.5.2Unsupported
cefsharp/67339620154.5.2Unsupported
cefsharp/65332520154.5.2Unsupported
cefsharp/63323920134.5.2Unsupported
cefsharp/62320220134.5.2Unsupported
cefsharp/57298720134.5.2Unsupported
cefsharp/55288320134.5.2Unsupported
cefsharp/53278520134.5.2Unsupported
cefsharp/51270420134.5.2Unsupported
cefsharp/49262320134.0Unsupported
cefsharp/47252620134.0Unsupported
cefsharp/45245420134.0Unsupported
cefsharp/43235720124.0Unsupported
cefsharp/41227220124.0Unsupported
cefsharp/39217120124.0Unsupported
cefsharp/37206220124.0Unsupported

 

 

原文链接

https://blog.csdn.net/a497785609/article/details/80675436

 

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值