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
Branch | CEF Version | VC++ Version | .Net Version | Status |
---|---|---|---|---|
master | 3945 | 2015 | 4.5.2 | Development |
cefsharp/79 | 3945 | 2015 | 4.5.2 | Pre-Release |
cefsharp/77 | 3865 | 2015 | 4.5.2 | Unsupported |
cefsharp/75 | 3770 | 2015 | 4.5.2 | Release |
cefsharp/73 | 3683 | 2015 | 4.5.2 | Unsupported |
cefsharp/71 | 3578 | 2015 | 4.5.2 | Unsupported |
cefsharp/69 | 3497 | 2015 | 4.5.2 | Unsupported |
cefsharp/67 | 3396 | 2015 | 4.5.2 | Unsupported |
cefsharp/65 | 3325 | 2015 | 4.5.2 | Unsupported |
cefsharp/63 | 3239 | 2013 | 4.5.2 | Unsupported |
cefsharp/62 | 3202 | 2013 | 4.5.2 | Unsupported |
cefsharp/57 | 2987 | 2013 | 4.5.2 | Unsupported |
cefsharp/55 | 2883 | 2013 | 4.5.2 | Unsupported |
cefsharp/53 | 2785 | 2013 | 4.5.2 | Unsupported |
cefsharp/51 | 2704 | 2013 | 4.5.2 | Unsupported |
cefsharp/49 | 2623 | 2013 | 4.0 | Unsupported |
cefsharp/47 | 2526 | 2013 | 4.0 | Unsupported |
cefsharp/45 | 2454 | 2013 | 4.0 | Unsupported |
cefsharp/43 | 2357 | 2012 | 4.0 | Unsupported |
cefsharp/41 | 2272 | 2012 | 4.0 | Unsupported |
cefsharp/39 | 2171 | 2012 | 4.0 | Unsupported |
cefsharp/37 | 2062 | 2012 | 4.0 | Unsupported |
原文链接
https://blog.csdn.net/a497785609/article/details/80675436