Skip to content

Feature Request - Add AnyCPU Support #1714

Closed
@amaitland

Description

@amaitland

UPDATE: Starting with release v87.1.132 the Nuget packages have been restructured to greatly simplify using AnyCPU. Issue #3319 has some specific information.

Those upgrading from versions prior to v87.1.132 shouldn't need to make any code changes.

Option 1

When targeting AnyCPU when your project has Prefer 32bit set to true then the resulting exe will be 32bit, the Nuget package checks for this and copies only the x86 files. This is the default for a number of Visual Studio project templates. No further changes are required.

To manually set Prefer 32bit open your project properties and under the build tab check prefer 32bit.

visualstudioprefer32bit

Option 2

Add a dependency resolver, this is more complicated and needs to be hooked up before any calls to classes in the CefSharp.* namespaces. Here is one method of doing this. It's important that LoadApp is not in-lined, so the calls to CefSharp are delayed long enough to hookup the Assembly Resolver

  • Add <CefSharpAnyCpuSupport>true</CefSharpAnyCpuSupport> to the first <PropertyGroup> in your project (e.g. .csproj file).
  • Implement the code below (modifying any setting that you require).
[STAThread]
public static void Main()
{
    CefRuntime.SubscribeAnyCpuAssemblyResolver();

    LoadApp();
}

[MethodImpl(MethodImplOptions.NoInlining)]
private static void LoadApp()
{
    var settings = new CefSettings();

    Cef.Initialize(settings, performDependencyCheck: true, browserProcessHandler: null);

    var browser = new BrowserForm();
    Application.Run(browser);
}

The MinimalExample now has AnyCPU as a target to demo the CefSharpAnyCpuSupport option.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions