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