See the Documentation: General Usage Guide
There are several solutions to enable AnyCPU Support. I have used the following:
First, install the dependencies via NuGet.
Then, add <CefSharpAnyCpuSupport>true</CefSharpAnyCpuSupport> to the first PropertyGroup of the .csproj file containing the CefSharp.Wpf PackageReference for the CefSharp.Wpf.ChromiumWebBrowser Control.
Now, write an Assembly Resolver to find the correct unmanaged DLLs depending on the current architecture:
AppDomain.CurrentDomain.AssemblyResolve += OnAssemblyResolve;
private Assembly OnAssemblyResolve(object sender, ResolveEventArgs args)
{
if (args.Name.StartsWith("CefSharp"))
{
string assemblyName = args.Name.Split(new[] { ',' }, 2)[0] + ".dll";
string architectureSpecificPath = Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase,
Environment.Is64BitProcess ? "x64" : "x86",
assemblyName);
return File.Exists(architectureSpecificPath)
? Assembly.LoadFile(architectureSpecificPath)
: null;
}
return null;
}
Finally, initialize CefSharp with at least these settings:
var settings = new CefSettings()
{
BrowserSubprocessPath = Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase,
Environment.Is64BitProcess ? "x64" : "x86",
"CefSharp.BrowserSubprocess.exe")
};
Cef.Initialize(settings);