Embed a Chrome browser in a. NET program using Cefsharp (a)--introduction

Source: Internet
Author: User

Sometimes, we need to embed a Web browser in the program, in fact, the. Net framework itself provides the WebBrowser control, itself this is the most simple and easy-to-use solution, but do not know what the reason, this control when browsing the web, some inexplicable lag, Sometimes it can even reach several seconds, seriously affecting the experience.

At this time, we can consider using a third-party browser instead of the system's WebBrowser, the common scenario is to use the version of the Chrome,chrome itself provides a program for third-party programs embedded in the Chromium Embedded Framework (CEF), But this is the interface of C + +, and there is a certain amount of work to be used in. NET programs. However, there are already some open source projects to complete this package, one of the best is the CEFSHARP,WPF and WinForm package is implemented, this article briefly describes how to use the Cefsharp in a WPF program to embed Chrome browser.

Installation:

The installation process is simple, as long as you install CEFSHARP.WPF with NuGet.

???? Pm> Install-package CEFSHARP.WPF

The installation process itself is relatively routine, but it is worth mentioning that this package is very large, due to the integration of the x86 and x64 versions, the entire package (plus a few dependent packages) reached more than 200 MB, based on well-known reasons, and NuGet access has been not smooth, and sometimes the whole process of convulsions is very long, Be patient and character.

?

To modify the compilation options:

Because Chrome is a native program, currently CEFSHARP is not able to do 32-bit and 64-bit automatic recognition, cannot use the default ANYCPU compilation options, need to modify the Configuration Manager, change to x86 or x64.

?

Use:

The use of the process is relatively simple, directly using the following code.

????PrivatevoidMainwindow_loaded (ObjectSenderRoutedEventArgsE
???? {
????????Var setting = new Cefsharp.cefsettings ();
???????? Cefsharp. ceftruefalse
???????? var WebView = new CEFSHARP.WPF. chromiumwebbrowser???????? this
???????? webview.address = "http://www.cnblogs.com/TianFang/" ????}

This article is just a brief introduction of the basic usage of cefsharp, the next article in the next introduction more about how to do more in-depth customization, on the CEFSHARP website itself has a more detailed example, interested friends can study.

?

Embed a Chrome browser in a. NET program using Cefsharp (a)--introduction

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.