-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature Request - Add AnyCPU Support #1714
Comments
Example You must add public partial class App : Application
{
public App()
{
CefRuntime.SubscribeAnyCpuAssemblyResolver();
//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();
Cef.Initialize(settings, performDependencyCheck: true, browserProcessHandler: null);
}
} The MinimalExample now has |
I've updated the original issue at the top here to include details about adding a |
This comment has been minimized.
This comment has been minimized.
The above warning in your |
You must add Option 3I've not tested this option in any great detail, so use at you own risk. It requires the user to have Write Permission to the applications executing folder. No special resolves or methods of loading the
NOTE
//Example WinForms Code (WPF would be very similar)
[STAThread]
public static void Main()
{
var executingFolder = AppDomain.CurrentDomain.SetupInformation.ApplicationBase;
//If libcef.dll doesn't exist in our executing folder then we'll copy the files
//For this method the user must have write permissions to the executing folder.
if (!File.Exists(Path.Combine(executingFolder, "libcef.dll")))
{
var libPath = Path.Combine(executingFolder, Environment.Is64BitProcess ? "x64" : "x86");
CopyFilesRecursively(new DirectoryInfo(libPath), new DirectoryInfo(executingFolder));
Directory.Delete("x86", recursive: true);
Directory.Delete("x64", recursive: true);
}
LoadApp();
}
//https://stackoverflow.com/a/58779/4583726
private static void CopyFilesRecursively(DirectoryInfo source, DirectoryInfo target)
{
foreach (DirectoryInfo dir in source.GetDirectories())
{
CopyFilesRecursively(dir, target.CreateSubdirectory(dir.Name));
}
foreach (FileInfo file in source.GetFiles())
{
file.CopyTo(Path.Combine(target.FullName, file.Name));
}
}
[MethodImpl(MethodImplOptions.NoInlining)]
private static void LoadApp()
{
//Perform dependency check to make sure all relevant resources are in our output directory.
var settings = new CefSettings();
Cef.Initialize(settings, performDependencyCheck: false, browserProcessHandler: null);
var browser = new BrowserForm();
Application.Run(browser);
} |
Examples of all three options can be found at https://github.com/cefsharp/CefSharp.MinimalExample/branches/all?utf8=%E2%9C%93&query=anycpu |
Starting with release v87.1.132 there is another option for Option 4
The resulting THIS IS AN EXAMPLE OF THE GENERATED APP.CONFIG, NO CODE CHANGES ARE REQUIRED <?xml version="1.0"?>
<configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2"/></startup>
<!--<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<probing privatePath="MyCefSharpTargetDir"/>
</assemblyBinding>
</runtime>-->
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="CefSharp.Core.Runtime" processorArchitecture="x86" publicKeyToken="40c4b6fc221f4138" culture="neutral"/>
<codeBase version="89.0.170.0" href="x86/CefSharp.Core.Runtime.dll"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="CefSharp.Core.Runtime" processorArchitecture="amd64" publicKeyToken="40c4b6fc221f4138" culture="neutral"/>
<codeBase version="89.0.170.0" href="x64/CefSharp.Core.Runtime.dll"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration> |
UPDATE: Starting with release v87.1.132 the
Nuget
packages have been restructured to greatly simplify usingAnyCPU
. 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 hasPrefer 32bit
set totrue
then the resultingexe
will be32bit
, theNuget
package checks for this and copies only thex86
files. This is the default for a number ofVisual 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.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 thatLoadApp
is not in-lined, so the calls toCefSharp
are delayed long enough to hookup theAssembly Resolver
<CefSharpAnyCpuSupport>true</CefSharpAnyCpuSupport>
to the first<PropertyGroup>
in your project (e.g..csproj
file).The MinimalExample now has
AnyCPU
as a target to demo theCefSharpAnyCpuSupport
option.The text was updated successfully, but these errors were encountered: