CefSharp For WPF基本使用
Nuget引用
CefSharp.Wpf
CefSharp.Common
cef.redist.x64
cef.redist.x86
直接搜索安装CefSharp.Wpf即可,因为CefSharp.Wpf依赖于其他三个包,所以会自动安装四个包

先更改设置
指定特定的平台,x64或者x86,默认是Any CPU
不进行配置的话,CefSharp是不支持Any CPU的

WPF写法
xmlns:cefSharpWPF="clr-namespace:CefSharp.Wpf;assembly=CefSharp.Wpf"
<cefSharpWPF:ChromiumWebBrowser Address="url"></cefSharpWPF:ChromiumWebBrowser>
Any CPU的支持
using System.Windows;
using System;
using System.Runtime.CompilerServices;
using CefSharp;
using System.IO;
using System.Reflection;
using System.Windows.Threading;
using CefSharpWpfDemo.Log;
namespace CefSharpWpfDemo
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
public App()
{
// Add Custom assembly resolver
AppDomain.CurrentDomain.AssemblyResolve += Resolver;
//Any CefSharp references have to be in another method with NonInlining
// attribute so the assembly rolver has time to do it's thing.
InitializeCefSharp();
}
[MethodImpl(MethodImplOptions.NoInlining)]
private static void InitializeCefSharp()
{
var settings = new CefSettings();
// Set BrowserSubProcessPath based on app bitness at runtime
settings.BrowserSubprocessPath = Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase,
Environment.Is64BitProcess ? "x64" : "x86",
"CefSharp.BrowserSubprocess.exe");
// Make sure you set performDependencyCheck false
Cef.Initialize(settings, performDependencyCheck: false, browserProcessHandler: null);
}
// Will attempt to load missing assembly from either x86 or x64 subdir
// Required by CefSharp to load the unmanaged dependencies when running using AnyCPU
private static Assembly Resolver(object sender, ResolveEventArgs args)
{
if (args.Name.StartsWith("CefSharp"))
{
string assemblyName = args.Name.Split(new[] { ',' }, 2)[0] + ".dll";
string archSpecificPath = Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase,
Environment.Is64BitProcess ? "x64" : "x86",
assemblyName);
return File.Exists(archSpecificPath)
? Assembly.LoadFile(archSpecificPath)
: null;
}
return null;
}
}
}
相关资料
https://github.com/cefsharp/CefSharp/issues/1714
示例代码
https://github.com/zLulus/NotePractice/tree/dev3/WPF/CefSharpWpfDemo
官方资料
https://www.codeproject.com/Articles/881315/Display-HTML-in-WPF-and-CefSharp-Tutorial-Part
https://github.com/cefsharp/CefSharp/wiki/Quick-Start
http://cefsharp.github.io/
CefSharp For WPF基本使用的更多相关文章
- CefSharp For WPF自定义右键菜单栏
原文:CefSharp For WPF自定义右键菜单栏 初始化 <!--浏览器--> <cefSharpWPF:ChromiumWebBrowser Name="webBr ...
- CefSharp For WPF隐藏滚动条
效果:开始的时候会显示几秒,之后就不会再显示了 <!--浏览器--> <cefSharpWPF:ChromiumWebBrowser Name="webBrowser&qu ...
- CefSharp For WPF响应页面点击事件
初始化 <!--浏览器--> <cefSharpWPF:ChromiumWebBrowser Name="webBrowser" Grid.Row="0 ...
- 修复CefSharp浏览器组件中文输入Bug
概述 最近在win10上开发wpf应用,需要将CefSharp中wpf版本的浏览器组件(版本号v51.0.0)嵌入到应用中,但是发现不支持中文输入,GitHub上有这个问题的描述,参照其提到的方法可以 ...
- 使用CefSharp在.Net程序中嵌入Chrome浏览器(一)——简介
有的时候,我们需要在程序中嵌入Web浏览器,其实.Net Framework中本身就提供了WebBrowser控件,本身这个是最简单易用的方案,但不知道是什么原因,这个控件在浏览网页的时候有些莫名的卡 ...
- C#:在AnyCPU模式下使用CefSharp
------------吾亦无他,唯手熟尔,谦卑若愚,好学若饥------------- 本篇博客讲述如何在AnyCPU模式下使用CefSharp 因为在某些情况下,不得不用AnyCPU,但是CefS ...
- WPF学习目录
基本概念 数据源Source-目标Target WPF生命周期 App.xaml 依赖属性 WPF路由 线程操纵UI问题 利用属性中设置.查看DataContext/Command等 分析布局 写数据 ...
- CefSharp部分效果实现
CefSharp For WPF隐藏滚动条 CefSharp For WPF自定义右键菜单栏 CefSharp For WPF响应页面点击事件
- 使用CefSharp在C#访问网站,支持x86和x64
早已久仰CefSharp大名,今日才得以实践,我其实想用CefSharp来访问网站页面,然后抓取html源代码进行分析,如果使用自带的WebBrowser控件,可能会出现一些不兼容js的错误. Cef ...
随机推荐
- 调试 之gdb thread命令 与 ltrace/strace
我们可以通过 1) gdb prog_name -> r 用在逐步调试自己的程序时 2) gdb -> attach process_id 正 ...
- 【45.65%】【codeforces 560B】Gerald is into Art
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
- (三)Unity5.0新特性------动画的StateMachineBehaviours
出处:http://blog.csdn.net/u010019717 author:孙广东 时间:2015.3.31 (State machine behaviours)状态机的行为在Ani ...
- 每天一个JavaScript实例-处理textarea中的字符成每一行
<!doctype html> <html lang="en"> <head> <meta charset="utf-8&quo ...
- 日志框架logj的使用
log4j 简介 是什么? Apache的一个开源的.轻量级的.用于日志管理的框架 有什么? Log4j由三个重要的组件构成:日志信息的输出格式,日志信息的优先 级,日志信息的输出目的地. 1,日志信 ...
- android studio 2.2 使用cmake编译NDK
Android studio 2.2 已经进入beta版本,新功能添加众多,NDK编程也得到了简化.官方博客介绍.本文介绍如何使用新版android studio调用 c++代码,为了超级通俗易懂,例 ...
- 【u210】kfc
Time Limit: 1 second Memory Limit: 128 MB [问题描述] 最近Kfc新开了个KFC,该KFC提供N种食物,分别用1-N给这些食物编号,食物的价格与其编号有关,满 ...
- php实现 明明的随机数
php实现 明明的随机数 一.总结 一句话总结: 1.asort是干嘛的? asort — 对数组进行排序并保持索引关系 2.从控制台取数据怎么取? trim(fgets(STDIN)) 3.多组测试 ...
- dom对象常用的属性和方法有哪些?
dom对象常用的属性和方法有哪些? 一.总结 一句话总结: 1.document属性和方法:document的属性有head,body之类,方法有各种获取element的方法 2.element的属性 ...
- java基础——try catch final
1.不管有木有出现异常,finally块中代码都会执行: 2.当try和catch中有return时,finally仍然会执行: 3.finally是在return后面的表达式运算后执行的(此时并没有 ...