从cefsharp57开始就支持anycpu了,不过需要一些设置:

1.首先要打开*.csprj文件,添加节点 <CefSharpAnyCpuSupport>true</CefSharpAnyCpuSupport>

<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
...
<CefSharpAnyCpuSupport>true</CefSharpAnyCpuSupport>
</PropertyGroup>

2.修改app.config文件

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

3.最后在App.xaml.cs的构造函数里添加:

  [MethodImpl(MethodImplOptions.NoInlining)]
private static void CefInit()
{
CefSharp.CefSettings settings = new CefSharp.CefSettings();
...
settings.BrowserSubprocessPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory,
Environment.Is64BitOperatingSystem ? "x64" : "x86",
"CefSharp.BrowserSubprocess.exe");
CefSharp.Cef.Initialize(settings, false, null);
}

编译运行,成功。

05-11 09:33
查看更多