{"record":{"id":"22a689d197667f4c","repo":"cefsharp/CefSharp","slug":"unable-to-load-for-arch-env","errorCode":null,"errorMessage":"Unable to load for arch {env}","messagePattern":"Unable to load for arch (.+?)","errorType":"exception","errorClass":"FileNotFoundException","httpStatus":null,"severity":"critical","filePath":"CefSharp/CefRuntime.cs","lineNumber":109,"sourceCode":"            const string assemblyName = \"CefSharp.Core.Runtime.dll\";\n\n            if (basePath == null)\n            {\n                basePath = AppDomain.CurrentDomain.SetupInformation.ApplicationBase;\n            }\n\n            var env = Environment.Is64BitProcess ? \"x64\" : \"x86\";\n            string archSpecificPath = Path.Combine(basePath,\n                                                   env,\n                                                   assemblyName);\n\n            if (File.Exists(archSpecificPath))\n            {\n                Assembly.LoadFile(archSpecificPath);\n            }\n            else\n            {\n                throw new FileNotFoundException(\"Unable to load for arch \" + env, archSpecificPath);\n            }\n        }\n    }\n}\n","sourceCodeStart":91,"sourceCodeEnd":114,"githubUrl":"https://github.com/cefsharp/CefSharp/blob/16bc6e0711a4945be17e8bc4bc7ccf9469f3fdec/CefSharp/CefRuntime.cs#L91-L114","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before — wrong basePath or missing folder\nCefRuntime.LoadCefSharpCoreRuntimeAnyCpu(); // defaults may be wrong\n\n// after — explicit correct path with verification\nvar baseDir = AppDomain.CurrentDomain.BaseDirectory;\nvar env = Environment.Is64BitProcess ? \"x64\" : \"x86\";\nvar expected = Path.Combine(baseDir, env, \"CefSharp.Core.Runtime.dll\");\nif (!File.Exists(expected))\n    throw new FileNotFoundException($\"Expected CefSharp.Core.Runtime.dll at {expected}\");\nCefRuntime.LoadCefSharpCoreRuntimeAnyCpu(baseDir);","handlingStrategy":"validation","validationCode":"var env = Environment.Is64BitProcess ? \"x64\" : \"x86\";\nvar archPath = Path.Combine(basePath ?? AppDomain.CurrentDomain.BaseDirectory, env, \"CefSharp.Core.Runtime.dll\");\nif (!File.Exists(archPath))\n{\n    throw new FileNotFoundException(\n        $\"CefSharp.Core.Runtime.dll not found at {archPath}. \" +\n        $\"Ensure the {env} folder exists with the runtime DLL.\");\n}\nCefRuntime.LoadCefSharpCoreRuntimeAnyCpu(basePath);","typeGuard":null,"tryCatchPattern":"try\n{\n    CefRuntime.LoadCefSharpCoreRuntimeAnyCpu(basePath);\n}\ncatch (FileNotFoundException ex) when (ex.Message.Contains(\"Unable to load for arch\"))\n{\n    Console.Error.WriteLine($\"Missing: {ex.FileName}\");\n    throw;\n}","preventionTips":["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."],"tags":["any-cpu","native-deps","architecture","startup","file-not-found"],"backgroundTag":null,"analyzedSha":"16bc6e0711a4945be17e8bc4bc7ccf9469f3fdec","analyzedAt":"2026-08-13T19:57:05.828Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}