Use Chromium as Web Browser in Visual Studio

Chromium as .Net Webbrowser

Internet Explorer is such a buggy software and it is even worse when you are using it as a browser for your Visual Studio / .NET program. It is not a big surprise why third party software was used widely naming Awesomium as one of the leading third party provider. It is mainly used in providing  HTML based UI for inline game stores.


Problems with the Default IE WebBrowser

The default webbrowser class is an emulation wrapper of IE 6 / IE 7 on top of the existing installed Internet Explorer. This pose a lot of problems due to inherent bugs and incomplete functionality of Internet Explorer.

There is no easy way to use the current installed browser other than hacking the registry which require an administrator access.

Webpages won’t render perfectly due to missing HTML 5 handling and proper CSS handling.

There are more issues related to how Microsoft have implemented the Web Browser class and one of the main trouble is generating a screenshot of webpages. For a developer and a data miner, this pose as a huge brick wall or a dead end.


What is Chromium

Chromium is the open-source web browser project from which Google Chrome draws its source code. The browsers share the majority of code and features, though there are some minor differences in features and they have different licensing.

In order to utilize Chromium as our default Web browser requires extensive programming to import the Dlls from the chromium project and embed it into our program. On the good side if you won’t bother loosing the capability to directly communicate with Chromium, you are in luck.

A github project called CefSharp will make the job easier and it is available in 3 library versions.

  1. Windows Forms
  2. Windows Presentation Foundation (WPF)
  3. Offscreen (No Visual Display)

Downloading CefSharp

CefSharp can be easily download using Visual Studios Package Manager. This is my favorite tool since it acts like CentOS’s yum module.

Installing CefSharp Library for WPF library using Install-Package CefSharp.Wpf

Installing CefSharp Library for WPF library using Install-Package CefSharp.Winforms

Finally, installing CefSharp Library for WPF library using Install-Package CefSharp.Offscreen


Using Chromium

There is a Minor Glitch (as noticed on my machine) in loading the libraries. After downloading and automatically importing the libraries, your project file will refuse to refresh. In order to fix reference issues, you should close the solution/project and reload.

Chromium currently have no easy way of adding the browser inside your toolbox so we are going to add it the old way in the cs source file.

And add it to our winform program using controls.add().

 

 


 

Chromium Inside a Windows Form

Verification test if we are really using Chromium / Chrome

Verification test if we are really using Chromium / Chrome

Verification test if we are really using Chromium / Chrome

Verification test if we are really using Chromium / Chrome

Enjoy!

coderinthebox

The TechnoJunkie of the group who studied engineering but got stuck with software development. Remember kids, 90% of your problems can be solved by marketing. Solving the other 10% just requires good procrastination skills.

You may also like...

Leave a Reply

%d bloggers like this: