当前位置: 首页 > backend >正文

制作浏览器CEFSharp133+X86+win7 之配置环境(一)

============================================

一定要设置项目为x86或者x64

=============================================
1、FrameWork

引用下面四个dll,并且不要输出到目录,属性==》复制到本地=》false
CefSharp.dll
CefSharp.Core.dll
CefSharp.Core.Runtime.dll
CefSharp.WinForms.dll


App.config

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup> 
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<probing privatePath="cef" />
</assemblyBinding>
</runtime>
</configuration>

====================================================
2、NetCore
引用下面三个dll,并且不要输出到目录,复制到本地==》否
CefSharp.dll
CefSharp.Core.dll
CefSharp.WinForms.dll

Program.cs
internal static class Program
{
/// <summary>
///  The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{

        //LoadFrom会自动加载依赖(如果程序集位于GAC中,则LoadFrom将自动加载GAC中的程序集)
Assembly.LoadFrom($@"{AppDomain.CurrentDomain.BaseDirectory}cef\CefSharp.dll");
Assembly.LoadFrom($@"{AppDomain.CurrentDomain.BaseDirectory}cef\CefSharp.Core.dll");
Assembly.LoadFrom($@"{AppDomain.CurrentDomain.BaseDirectory}cef\CefSharp.Core.Runtime.dll");
Assembly.LoadFrom($@"{AppDomain.CurrentDomain.BaseDirectory}cef\CefSharp.WinForms.dll");

        // To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
Application.Run(new Form1());
}
}

=======================================================


using CefSharp.WinForms;
using CefSharp;namespace TestCefCore
{public partial class Form1 : Form{public Form1(){InitializeComponent();var settings = new CefSettings(){Locale = "zh-CN",AcceptLanguageList = "zh-CN,zh;q=0.8",PersistSessionCookies = true,UserAgent = "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0 Safari/537.36",IgnoreCertificateErrors = true,LogSeverity = LogSeverity.Disable, //禁用日志//为空则将以“隐身模式”创建浏览器CachePath = AppDomain.CurrentDomain.BaseDirectory + "cef_cache",//Windows上用户“Local Settings\Application Data\CEF\User Data”目录RootCachePath = AppDomain.CurrentDomain.BaseDirectory + "cef_temp"};settings.CefCommandLineArgs.Add("disable-gpu", "1"); // 禁用gpusettings.CefCommandLineArgs.Add("no-proxy-server", "1"); //禁用代理settings.CefCommandLineArgs.Add("proxy-auto-detect", "0"); //禁用代理//settings.CefCommandLineArgs.Add("proxy-server", "ProxyAddress");settings.CefCommandLineArgs.Add("--disable-web-security", "1"); //允许跨域settings.CefCommandLineArgs.Add("--ignore-urlfetcher-cert-requests", "1");//忽略安全证书settings.CefCommandLineArgs.Add("--ignore-certificate-errors", "1");//忽略安全证书settings.CefCommandLineArgs.Add("enable-media-stream", "1"); //允许webRTC//settings.CefCommandLineArgs["enable-system-flash"] = "1";//settings.CefCommandLineArgs.Add("ppapi-flash-version", "32.0.0.171");//settings.CefCommandLineArgs.Add("ppapi-flash-path", @"plugins\pepflashplayer.dll");//Cef.EnableHighDPISupport();CefSharpSettings.ConcurrentTaskExecution = true;//CefSharpSettings.LegacyJavascriptBindingEnabled = true;//CefSharpSettings.WcfEnabled = true;Cef.Initialize(settings);}

窗口代码

  ChromiumWebBrowser webview;private void Form1_Shown(object sender, EventArgs e){var url = "https://www.tesla.cn/ownersmanual/modelx/en_qa/Owners_Manual.pdf";//url = "https://lib.tsinghua.edu.cn/wj/GBT7714-2015.pdf";//url = "https://www.baidu.com";url = "http://127.0.0.1:5500/index.html";webview = new ChromiumWebBrowser(url);webview.BrowserSettings.WebGl = CefState.Enabled;webview.Dock = DockStyle.Fill;Controls.Add(webview);}private void Form1_FormClosing(object sender, FormClosingEventArgs e){Cef.Shutdown();}}
}

阿雪技术观
在科技发展浪潮中,我们不妨积极投身技术共享。不满足于做受益者,更要主动担当贡献者。无论是分享代码、撰写技术博客,还是参与开源项目维护改进,每一个微小举动都可能蕴含推动技术进步的巨大能量。东方仙盟是汇聚力量的天地,我们携手在此探索硅基生命,为科技进步添砖加瓦。

Hey folks, in this wild tech - driven world, why not dive headfirst into the whole tech - sharing scene? Don't just be the one reaping all the benefits; step up and be a contributor too. Whether you're tossing out your code snippets, hammering out some tech blogs, or getting your hands dirty with maintaining and sprucing up open - source projects, every little thing you do might just end up being a massive force that pushes tech forward. And guess what? The Eastern FairyAlliance is this awesome place where we all come together. We're gonna team up and explore the whole silicon - based life thing, and in the process, we'll be fueling the growth of technology.

http://www.xdnf.cn/news/17345.html

相关文章:

  • Product Hunt 每日热榜 | 2025-08-09
  • 【C++详解】AVL树深度剖析与模拟实现(单旋、双旋、平衡因⼦更新、平衡检测)
  • 基于clodop和Chrome原生打印的标签实现方法与性能对比
  • 【MySQL】事务的基本概念
  • 揭秘MyBatis核心类MappedStatement
  • 【Datawhale AI夏令营】基于多模态RAG的企业财报问答系统
  • Vue3 生命周期
  • Go语言实战案例:表单提交数据解析
  • 多模态RAG赛题实战--Datawhale AI夏令营
  • 39.【.NET8 实战--孢子记账--从单体到微服务--转向微服务】--扩展功能--调整发布脚本
  • 通过 Docker 运行 Prometheus 入门
  • C# 通过第三方库INIFileParser管理INI配置文件
  • 2025年渗透测试面试题总结-09(题目+回答)
  • 实战:MyBatis 中 db.properties 的正确配置与最佳实践
  • RAGFoundry:面向检索增强生成的模块化增强框架
  • 五、RuoYi-Cloud-Plus 前端项目部署以及如何改后端请求地址。
  • 【CTF】PHP反序列化基础知识与解题步骤
  • Java 大视界 -- Java 大数据在智能医疗手术机器人操作数据记录与性能评估中的应用(390)
  • 深入剖析Spring MVC核心原理:从请求到响应的魔法解密
  • Java-线程线程的创建方式
  • 【线性代数】线性方程组与矩阵——(3)线性方程组解的结构
  • kubectl get node k8s-node01 -o yaml | grep taint -B 5 -A 5
  • 电子电气架构 --- 48V车载供电架构
  • 第16届蓝桥杯Scratch选拔赛初级及中级(STEMA)2024年11月24日真题
  • 阿里Qwen-Image本地部署详细指南
  • SAP在越南投资1.75亿美元建设研发中心
  • 多线程(四) --- 线程安全问题
  • JS逆向实战案例之----【通姆】252个webpack模块自吐
  • jQuery 零基础学习第一天
  • 进阶向:Python编写网页爬虫抓取数据