Click here to Skip to main content
14,608,081 members

Embedding Chrome in your C# App using CefSharp

Rate this:
4.80 (46 votes)
Please Sign up or sign in to vote.
4.80 (46 votes)
2 Sep 2016CPOL
Learn how to integrate the CefSharp open-source web browser into a C# WinForms app


Ever tried to integrate a reliable and fast web browser in your app only to jump through hoops trying?

In this tip, you will learn how easy it is to integrate the fantastic CefSharp web browser component (based on Chromium) into your C# app.

You can then use this web browser:

  • To give users an integrated browsing experience
  • To add embedded UI programmed in HTML/JavaScript
  • For web automation

CefSharp is reliable, fast, fully open-source and does not need any extra dependencies to be installed by end users (except VC++ Runtime 2013).

In this guide, we will use a WinForms project but CefSharp works equally well with WPF projects.

Getting Started

Follow these steps to quickly get started with CefSharp.


1. Create a Windows Forms Application (C#) project with .NET 4.5.2

2. Name your project (e.g. "CefTest")

Image 1

DLLs (NuGet Method)

3A) If you use NuGet, you can just grab CefSharp.WinForms from the NuGet repository, and skip the manual method below.

3B) If you used NuGet, navigate to SOLUTION > Configuration Manager and set your project to x86 or x64 since AnyCPU is not currently supported.

Image 2

DLLs (Manual Method)


3A)  Download the CefSharp binaries and unzip them.

3B)  Right click your project & click "Add Reference", then "Browse".

Image 3

3C)  Select these DLLs:

  • CefSharp.dll
  • CefSharp.Core.dll
  • CefSharp.WinForms.dll

Image 4

3D) Select all the files in the ZIP:

Image 5

3E)  Copy those files into your Project's Debug folder (inside Bin):

Image 6


4.  Right click your main form and select "View Code".

Image 7

5.  Add the following code:

Copy this into your import section:

using CefSharp;
using CefSharp.WinForms;     

Copy this into your code section:

public ChromiumWebBrowser browser;
public void InitBrowser(){
    Cef.Initialize(new CefSettings());
    browser = new ChromiumWebBrowser ("");
    browser.Dock = DockStyle.Fill;

Call InitBrowser() just after the call to InitializeComponent():


Your code should finally look like this:

Image 8


6.  Press F5 and you will see the Google homepage!

Image 9


An unhandled exception of type 'System.IO.FileNotFoundException' occurred in browser.exe
Additional information: Could not load file or assembly 'CefSharp.Core.dll' or one of its dependencies.

If you get this error, ensure you have Visual C++ 2013 Redistributable installed.


An unhandled exception of type 'System.BadImageFormatException' occurred in browser.exe
Additional information: Could not load file or assembly 'CefSharp.Core, Version=, Culture=neutral, 

If you get this error, it means you are on a 64-bit PC and your app is built in AnyCPU mode. You need to change this to x86 or x64 mode:

  1. Open the Solution Explorer panel
  2. Right click your project > Project Properties
  3. Click on the Build tab
  4. Change Platform target to x86 or x64

Full Featured Browsers

If you are looking for a full-featured browser project, then check out these open source browsers built with CefSharp in C#.


WPF. Address Bar with Suggestions, Multiple tabs, Downloads, Bookmarks, History.

<screenshot not provided by author>


Windows Forms. Address Bar, Multiple tabs, Downloads.

Sharp Browser


  • V1.0 - Published the article on Nov 23rd, 2015
  • V1.1 - Added troubleshooting guide on Nov 25th, 2015
  • V1.2 - Added NuGet guide and VS project ZIP on Nov 26th, 2015
  • V1.3 - Added troubleshooting tip for 64-bit PCs on Aug 6th 2016
  • V1.4 - Updated to CefSharp v51, and .NET 4.5.2 on Aug 28th 2016
  • V1.6 - Added SharpBrowser and WebExpress projects on Sep 2th 2016


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

No Biography provided

Comments and Discussions

QuestionWhat is Cef Pin
FatihTAN21-Oct-19 2:36
MemberFatihTAN21-Oct-19 2:36 
AnswerRe: What is Cef Pin
Prashant. B. Chavan30-Oct-19 3:05
MemberPrashant. B. Chavan30-Oct-19 3:05 
QuestionI am trying in vs2015 Community it is not showing properly Pin
Member 145496195-Sep-19 0:50
MemberMember 145496195-Sep-19 0:50 
Generalafter setup getting error Pin
sandipbh8-Jul-19 3:35
Membersandipbh8-Jul-19 3:35 
QuestionSimply does not work Pin
JohnHolliday21-Dec-18 12:44
MemberJohnHolliday21-Dec-18 12:44 
Questioncan not run Pin
Member 114970507-Nov-17 9:18
MemberMember 114970507-Nov-17 9:18 
QuestionIs there any alternative of webkitSpeechRecognition? its not working. Pin
Dilip Mevada12-Oct-17 2:02
MemberDilip Mevada12-Oct-17 2:02 
QuestionHow to enable microphone? in cefsharp for c# or Pin
Member 1285160120-Aug-17 4:53
MemberMember 1285160120-Aug-17 4:53 
QuestionApp is not getting open in Client System Pin
Member 1310214011-Jul-17 4:23
MemberMember 1310214011-Jul-17 4:23 
QuestionApp run but nothing Pin
dovper26-Apr-17 4:08
Memberdovper26-Apr-17 4:08 
QuestionHow to open multiple ChromiumWebBrowsers? Pin
LiQuick24-Jan-17 21:38
MemberLiQuick24-Jan-17 21:38 
QuestionHow to disabled update information? Pin
Augustyniak8-Jan-17 3:53
MemberAugustyniak8-Jan-17 3:53 
QuestionUse cefSharp in an ASP MVC App Pin
Hedi Sangoku8-Nov-16 10:00
MemberHedi Sangoku8-Nov-16 10:00 
QuestionInstalled using Nuget but getting error Pin
ehsan_kayani198626-Oct-16 21:15
Memberehsan_kayani198626-Oct-16 21:15 
AnswerRe: Installed using Nuget but getting error Pin
ehsan_kayani198627-Oct-16 1:52
Memberehsan_kayani198627-Oct-16 1:52 
QuestionResizing issue Pin
Schubbard31-Aug-16 0:27
MemberSchubbard31-Aug-16 0:27 
AnswerRe: Resizing issue Pin
Schubbard31-Aug-16 2:29
MemberSchubbard31-Aug-16 2:29 
GeneralRe: Resizing issue Pin
Robin Rodricks2-Sep-16 19:54
MemberRobin Rodricks2-Sep-16 19:54 
GeneralRe: Resizing issue Pin
Schubbard4-Sep-16 2:57
MemberSchubbard4-Sep-16 2:57 
GeneralRe: Resizing issue Pin
Robin Rodricks6-Sep-16 1:49
MemberRobin Rodricks6-Sep-16 1:49 
GeneralRe: Resizing issue Pin
Schubbard6-Sep-16 2:02
MemberSchubbard6-Sep-16 2:02 
GeneralRe: Resizing issue Pin
Member 1043519618-Sep-16 5:49
professionalMember 1043519618-Sep-16 5:49 
GeneralRe: Resizing issue Pin
Schubbard18-Sep-16 22:56
MemberSchubbard18-Sep-16 22:56 
SuggestionI think you should use Nuget Pin
comwrg28-Aug-16 16:01
Membercomwrg28-Aug-16 16:01 
GeneralRe: I think you should use Nuget Pin
Robin Rodricks2-Sep-16 19:55
MemberRobin Rodricks2-Sep-16 19:55 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Posted 22 Nov 2015

Tagged as


71 bookmarked