Skip to content
Alex Maitland edited this page Feb 14, 2022 · 47 revisions

To get started with CefSharp checkout the CefSharp.MinimalExample project here on GitHub. The project contains basic working examples of the WinForms, WPF and OffScreen versions.

Installation (MS .Net 4.5.2, .Net 4.6.x, .Net 4.7.x and .Net 4.8)

  • Install one of the following via the Nuget Package Manager from within Visual Studio

    • CefSharp.WinForms
    • CefSharp.Wpf
    • CefSharp.OffScreen
  • Review the Post Installation steps in the Readme.txt file that's opened in Visual Studio upon installation.

  • Review the Release Notes for the version you just installed, a list of Known Issues for the problems we're currently aware of.

  • Check out the API Doc, it's version specific, make sure you pick the correct version.

  • When targeting AnyCPU with Prefer32bit = true then no further action is required. Your application is 32bit and will include the 32bit binaries/resources.

  • When targeting AnyCPU please see https://github.com/cefsharp/CefSharp/issues/1714. The MinimalExample demos AnyCPU support and can be used as a reference.

  • For architecture specific builds then set your PlatformTarget to x86 or x64.

Installation (MS .Net Core 3.1/.Net 5.0/.Net 6.0)

  • Install one of the following via the Nuget Package Manager from within Visual Studio

    • CefSharp.WinForms.NETCore
    • CefSharp.Wpf.NETCore
    • CefSharp.OffScreen.NETCore
  • Review the Post Installation steps in the Readme.txt file that's opened in Visual Studio upon installation.

  • Review the Release Notes for the version you just installed, a list of Known Issues for the problems we're currently aware of.

  • Check out the API Doc, it's version specific, make sure you pick the correct version.

Code Examples

  • Add a new instance of the browser
    • For WPF use CefSharp.Wpf.ChromiumWebBrowser
      <!-- Add a xmlns:wpf="clr-namespace:CefSharp.Wpf;assembly=CefSharp.Wpf" attribute to your parent control -->
      <!-- Create a new instance in code or in `xaml` -->
      <Border Grid.Row="1" BorderBrush="Gray" BorderThickness="0,1">
          <wpf:ChromiumWebBrowser x:Name="Browser" Address="www.google.com"/>
      </Border>
    • For WinForms use CefSharp.WinForms.ChromiumWebBrowser
      using CefSharp.WinForms;
      //Create a new instance in code or add via the designer
      var browser = new ChromiumWebBrowser("www.google.com");
      parent.Controls.Add(browser);
      
      //Load a different url
      browser.LoadUrl("https://github.com");
    • For OffScreen use CefSharp.OffScreen.ChromiumWebBrowser
      using CefSharp.OffScreen;
      //Create a new instance in code
      var browser = new ChromiumWebBrowser("www.google.com");
      
      //Load a different url
      browser.LoadUrl("https://github.com");

TODO: Improve formatting, anyone with a GitHub account can help improve this wiki. Please help out!


Third-Party Articles

The following articles are unfortunately outdated, if you have written a new up to date article please include a link to it here.

WinForms C#

WinForms VB.Net

WPF C#

WPF VB.Net

  • Quick Start Guide (This guide is outdated, if someone has a newer one please add a link).