AUTHOR: Desislava Yordanova
DATE POSTED: January 31, 2018
This article demonstrates a sample approach how to embed Chrome in your application.
Integrate the CefSharp web browser component (based on Chromium) into your C# application. CefSharp is reliable, fast, fully open-source and does not need any extra dependencies to be installed by end users (except VC++ Runtime 2013).
1A. NuGet method – if you use NuGet, you can just grab CefSharp.WinForms from the NuGet repository.
Navigate to Solution > Configuration Manager and set your project to x86 or x64 since AnyCPU is not currently supported.
1B. Manual method – download the CefSharp binaries and unzip them.
CefSharp v51 x86 (for 32-bit apps)
CefSharp v51 x64 (for 64-bit apps)
- Right click your project, select "Add Reference", then "Browse":
- Select the following DLLs:
- Select all the files in the ZIP and copy those files into your Project's Debug folder (inside Bin):
2. Add the following code:
- Copy this to your import section:
- Copy this to your code section:
browser.Dock = DockStyle.Fill;
- Call InitBrowser() just after the call of InitializeComponent():
When you run the application, you have Chromium embedded in your Windows Forms project:
sender, LoadingStateChangedEventArgs e)
"alert('All Resources Have Loaded');"
Depending on the version of the CefSharp you are currently using your application may require .NET Framework 4.0 and higher. Please refer to release branches section.
The attached zip file provides a sample application with a C#/VB.NET project.