cefsharp/CefSharp · critical · FileNotFoundException
Unable to load for arch {env}
Error message
Unable to load for arch {env} What it means
LoadCefSharpCoreRuntimeAnyCpu immediately loads CefSharp.Core.Runtime.dll from an architecture-specific subfolder (x64 or x86) under basePath. If the file does not exist at that path, FileNotFoundException is thrown with 'Unable to load for arch x64' (or x86) and the expected file path.
Source
Thrown at CefSharp/CefRuntime.cs:109
const string assemblyName = "CefSharp.Core.Runtime.dll";
if (basePath == null)
{
basePath = AppDomain.CurrentDomain.SetupInformation.ApplicationBase;
}
var env = Environment.Is64BitProcess ? "x64" : "x86";
string archSpecificPath = Path.Combine(basePath,
env,
assemblyName);
if (File.Exists(archSpecificPath))
{
Assembly.LoadFile(archSpecificPath);
}
else
{
throw new FileNotFoundException("Unable to load for arch " + env, archSpecificPath);
}
}
}
}
View on GitHub (pinned to 16bc6e0711)
Solutions
- Verify the basePath folder structure: <basePath>/x64/CefSharp.Core.Runtime.dll and <basePath>/x86/CefSharp.Core.Runtime.dll must both exist for AnyCPU.
- Pass the correct basePath — if null, it defaults to AppDomain.CurrentDomain.SetupInformation.ApplicationBase, which may not be where the files are.
- Ensure the CefSharp NuGet packages and AfterBuild targets ran for both architectures during build.
Example fix
// before — wrong basePath or missing folder
CefRuntime.LoadCefSharpCoreRuntimeAnyCpu(); // defaults may be wrong
// after — explicit correct path with verification
var baseDir = AppDomain.CurrentDomain.BaseDirectory;
var env = Environment.Is64BitProcess ? "x64" : "x86";
var expected = Path.Combine(baseDir, env, "CefSharp.Core.Runtime.dll");
if (!File.Exists(expected))
throw new FileNotFoundException($"Expected CefSharp.Core.Runtime.dll at {expected}");
CefRuntime.LoadCefSharpCoreRuntimeAnyCpu(baseDir); Defensive patterns
Strategy: validation
Validate before calling
var env = Environment.Is64BitProcess ? "x64" : "x86";
var archPath = Path.Combine(basePath ?? AppDomain.CurrentDomain.BaseDirectory, env, "CefSharp.Core.Runtime.dll");
if (!File.Exists(archPath))
{
throw new FileNotFoundException(
$"CefSharp.Core.Runtime.dll not found at {archPath}. " +
$"Ensure the {env} folder exists with the runtime DLL.");
}
CefRuntime.LoadCefSharpCoreRuntimeAnyCpu(basePath); Try / catch
try
{
CefRuntime.LoadCefSharpCoreRuntimeAnyCpu(basePath);
}
catch (FileNotFoundException ex) when (ex.Message.Contains("Unable to load for arch"))
{
Console.Error.WriteLine($"Missing: {ex.FileName}");
throw;
} Prevention
- Verify both x64/ and x86/ subfolders with CefSharp.Core.Runtime.dll exist for AnyCPU builds.
- Pass an explicit basePath rather than relying on the default ApplicationBase.
- Ensure build targets ran for both architectures.
When it happens
Trigger: Calling CefRuntime.LoadCefSharpCoreRuntimeAnyCpu(basePath) when basePath does not contain an x64 or x86 subdirectory with CefSharp.Core.Runtime.dll, or the subfolder for the current process bitness is missing.
Common situations: AnyCPU deployment where the build output does not have the x86/x64 folder structure. Wrong basePath passed (e.g. a temp publish directory that wasn't fully populated). MSBuild platform configuration that skipped one architecture.
Related errors
- NotFound
- Cef.Initialize() failed.Check the log file see https://githu
- UseAnyCpuAssemblyResolver has already been called, call
- Unable to locate required Cef/CefSharp dependencies:
- Unable to Initialize Cef
AI-assisted analysis of cefsharp/CefSharp@16bc6e0711 (2026-08-13).
Data as JSON: /api/errors/22a689d197667f4c.
Report an issue: GitHub.