|
|
Posted on 4/2/2019 8:31:40 PM
|
|
|
|

I actually want to use CefSharp to access website pages, and then grab the html source code for analysis, if you use the built-in WebBrowser control, there may be some js incompatible errors.
CefSharp allows you to embed Chromium in .NET applications. It is a lightweight .NET wrapper around the Chromium Embedded Framework (CEF) by Marshall A. Greenblatt. About 30% of the bindings are written in C++/CLI, and most of the code here is in C#. It can be used from C# or VB or any other CLR language. CefSharp provides WPF and WinForms web browser control implementations. GitHub address:The hyperlink login is visible.
First, I use VS to create a new winform project with the following environment:
- . .NET framework version: 4.6.2
- Visual Studio 2013: And above, I'm using vs2017 here
The nuget command is as follows:
After execution is complete, the program automatically adds dependency packages as follows:
<?xml version="1.0" encoding="utf-8"?> <packages> <package id="cef.redist.x64" version="3.3578.1870" targetFramework="net462" /> <package id="cef.redist.x86" version="3.3578.1870" targetFramework="net462" /> <package id="CefSharp.Common" version="71.0.2" targetFramework="net462" /> <package id="CefSharp.WinForms" version="71.0.2" targetFramework="net462" /> </packages> After the installation is completed, the compilation project will report the following error:
CefSharp.Common contains unmanaged resoures, set your project and solution platform to x86 or x64. Alternatively for AnyCPU Support seeThe hyperlink login is visible. I saw a solution on the Internet that says change the active solution platform to x86 (CEF cannot adapt to x86 | x64, you must choose a target), and the target platform must also be consistent with the solution platform.
Starting with CefSharp 51, you can use CefSharp with AnyCPU, but it doesn't work alone because you need to make some changes in 2 specific files. According to the method of netizens, it should be solved, I didn't try, in fact, cef already supports AnyCPU, but it needs to be configured, the configuration scheme is as follows:
1: First right-click on the project, uninstall the solution, edit the .csproj file of the project, and add it to <PropertyGroup>the first node:
2: After the addition is complete, reload the project and add the following configuration in app.config:
3: Before calling Cef.Initialize, configure the browser startup path with the following code:
Solution Reference:The hyperlink login is visible.
The completed code is as follows:
Run Projects:
Resources:https://ourcodeworld.com/article ... informs-application
(End)
|
Previous:java gets the Object property type, property name, and property valueNext:Visual Studio 2019 offline download and installation tutorial
|