Tuesday, 4 November 2014

C# and VB.NET - Google Chrome WebBrowser Control for WinForms and WPF


Anybody that has used the inbuilt WebBrowser control in WinForms and WPF has noticed that it's an old version of Internet Explorer can throws a lot of script errors, renders pages badly and is prone to memory leaks.

This blog post will provide a little insight into using The Chromium Embedded Framework (CEF) as an alternative. Chromium in a nutshell is basically a development release of Google Chrome. When a chosen release has been put through testing and deployed, it is a simply a new version of Google Chrome.

Chromium Embedded Framework (CEF) is an open source project and actively maintained (As of 2014)... These are two good things we look for when re-using existing development frameworks. You can visit the CEF development page here.

External Projects
The base CEF framework includes support for the C and C++ programming languages. Thanks to the hard work of external maintainers CEF can integrate with a number of other programming languages and frameworks. These external projects are not maintained by CEF so please contact the respective project maintainer if you have any questions or issues.

.Net - https://github.com/chillitom/CefSharp
.Net (CEF1) - https://bitbucket.org/fddima/cefglue
.Net/Mono (CEF3) - https://bitbucket.org/xilium/xilium.cefglue
Delphi (CEF1) - http://code.google.com/p/delphichromiumembedded/
Delphi (CEF3) - http://code.google.com/p/dcef3/
Go - https://github.com/CzarekTomczak/cef2go
Java - http://code.google.com/p/javachromiumembedded/
Java - http://code.google.com/p/javacef/
Python - http://code.google.com/p/cefpython/

For C# and VB.NET applications, I recommend CefSharp. Download via NuGet and add to your project with ease!

CefSharp
This project contains .NET CLR bindings for The Chromium Embedded Framework (CEF) by Marshall A. Greenblatt. A small Core of the bindings are written in C++/CLI but the majority of code here is C#. It can of course be used from any CLR language, e.g. C# or VB.

CefSharp provides both WPF and WinForms web browser control implementations. See the CefSharp.Wpf.Example or CefSharp.WinForms.Example projects for example web browsers built using this library; they are (at this moment) the best "documentation" of features. In addition see the CefSharp.MinimalExample repo for how CefSharp can actually be used via NuGet packages.

No comments: