Embed Chrome browser usage in C # user controls using Cefsharp

Source: Internet
Author: User

CEF (Chromium Embedded Framework, Embedded Chromium framework) is a library developed by C/
At present, Google Chrome (Google browser), Chromium browser, opera, etc. are based on the CEF-centric, WebKit engine browser.


Xilium.cefglue is a. NET wrapper on the CEF project, and it is a p/invoke way to invoke the CEF class library.
Cefsharp calls the CEF class library in the form of C + +/CLI.

Originally used is xilium.cefglue, if it is simply implemented in the window is not a problem, because I need to make the user control, so the call when some DLL files can not be called, the user control does not load properly onto the WinForm window, Later switched to Cefsharp

I. Development environment


VS2010 + cefsharp 49.0.1

Two. Development steps (Take cefsharp as an example)

1. New Windows Forms application Googlewebbrowsercontrol, using the. NET Framework 4.0, it is important to note that the CEFSHARP and. NET Framework versions should correspond.

2. In the build = Configuration Manager, change the active solution platform to x86 (CEF is not adaptive x86 | x64, a target must be selected), and the target platform must be consistent with the solution platform.


3. For VS2010, the default is no NuGet Package Manager, you need to add the NuGet packages Manager in the VS Toolbar-Extension Manager

4. Open the NuGet Package Manager console: Tools =>nuget Package Manager = "Package Manager console." Search for Cefsharp.winform, select the version and the items that need to be added, add all the required files to the selected project after installation, and add the DLL files to the import.

5. If you have cefsharp all the required files have been downloaded to the local, then the 3rd, 4 steps do not need to operate, directly download the file into the project debug, will CefSharp.Core.dll, CefSharp.dll, The CefSharp.WinForms.dll file is introduced into the project.

6. Code Writing

Note: When a user control generates a Google kernel browser control, the code that is initialized by the Google Kernel Browser control cannot be loaded directly in the user control, and the method must be called in the page that uses the user control. Otherwise the error.
Optional: (View CEF-related packages)

7. Create a new project, use this user control in your project, and call directly in the background code

The following results are performed:

Source cannot be uploaded

Embed Chrome browser usage in C # user controls using Cefsharp

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.