{"record":{"id":"fc67fdfb84f6d727","repo":"cefsharp/CefSharp","slug":"notfound","errorCode":null,"errorMessage":"NotFound","messagePattern":"NotFound","errorType":"exception","errorClass":"FileNotFoundException","httpStatus":null,"severity":"critical","filePath":"CefSharp/CefLibraryHandle.cs","lineNumber":43,"sourceCode":"        private enum LoadLibraryFlags : uint\n        {\n            DONT_RESOLVE_DLL_REFERENCES = 0x00000001,\n            LOAD_IGNORE_CODE_AUTHZ_LEVEL = 0x00000010,\n            LOAD_LIBRARY_AS_DATAFILE = 0x00000002,\n            LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE = 0x00000040,\n            LOAD_LIBRARY_AS_IMAGE_RESOURCE = 0x00000020,\n            LOAD_WITH_ALTERED_SEARCH_PATH = 0x00000008\n        }\n\n        /// <summary>\n        /// Initializes a new instance of the CefLibraryHandle class.\n        /// </summary>\n        /// <param name=\"path\">libcef.dll full path.</param>\n        public CefLibraryHandle(string path) : base(IntPtr.Zero, true)\n        {\n            if (!File.Exists(path))\n            {\n                throw new FileNotFoundException(\"NotFound\", path);\n            }\n\n            var handle = LoadLibraryEx(path, IntPtr.Zero, LoadLibraryFlags.LOAD_WITH_ALTERED_SEARCH_PATH);\n            base.SetHandle(handle);\n        }\n\n        /// <summary>\n        /// When overridden in a derived class, gets a value indicating whether the handle value is invalid.\n        /// </summary>\n        /// <value>\n        /// true if the handle value is invalid; otherwise, false.\n        /// </value>\n        public override bool IsInvalid\n        {\n            get { return handle == IntPtr.Zero; }\n        }\n\n        /// <summary>","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/cefsharp/CefSharp/blob/16bc6e0711a4945be17e8bc4bc7ccf9469f3fdec/CefSharp/CefLibraryHandle.cs#L25-L61","documentation":"CefLibraryHandle is a SafeHandle that loads libcef.dll via LoadLibraryEx during construction. If the DLL file does not exist at the given path, FileNotFoundException is thrown with 'NotFound' as the message and the path as the fileName. This is the earliest failure point for native CEF loading.","triggerScenarios":"Cef.Initialize internally creates a CefLibraryHandle with the resolved libcef.dll path. If the file is absent — wrong working directory, incomplete deployment, or a misconfigured BrowserSubProcessPath — File.Exists returns false and the exception fires.","commonSituations":"Running the app from a directory that does not contain libcef.dll. Build output missing native files due to a broken AfterBuild target or failed NuGet restore. Publishing/deploying without the CEF redist files. 32-bit process looking in the wrong folder.","solutions":["Verify libcef.dll exists in the same directory as the executing assembly (or in the path you configured).","Clean-rebuild the project to let CefSharp.AfterBuild.targets copy all native files.","If using AnyCPU, ensure the x86/x64 subfolders each contain libcef.dll.","Check that the working directory at runtime matches where the binaries are deployed."],"exampleFix":"// before — app runs from a different directory, libcef.dll not found\nvar settings = new CefSettings { BrowserSubprocessPath = \"CefSharp.BrowserSubProcess.exe\" };\nCef.Initialize(settings);\n\n// after — use absolute paths\nvar baseDir = AppDomain.CurrentDomain.BaseDirectory;\nvar settings = new CefSettings\n{\n    BrowserSubprocessPath = Path.Combine(baseDir, \"CefSharp.BrowserSubProcess.exe\")\n};\nCef.Initialize(settings, performDependencyCheck: true);","handlingStrategy":"validation","validationCode":"var libcefPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, \"libcef.dll\");\nif (!File.Exists(libcefPath))\n{\n    throw new FileNotFoundException(\n        $\"libcef.dll not found at {libcefPath}. \" +\n        \"Ensure CEF NuGet packages are restored and AfterBuild targets ran.\");\n}\n// safe to initialize CEF now","typeGuard":null,"tryCatchPattern":"try\n{\n    Cef.Initialize(settings);\n}\ncatch (FileNotFoundException ex) when (ex.Message == \"NotFound\")\n{\n    Console.Error.WriteLine($\"libcef.dll missing at: {ex.FileName}\");\n    throw;\n}","preventionTips":["Always verify libcef.dll exists in the output directory before running.","Clean-rebuild to ensure CefSharp.AfterBuild.targets copies all native files.","Use absolute paths for BrowserSubprocessPath and resource directories."],"tags":["native-deps","libcef","startup","file-not-found"],"backgroundTag":null,"analyzedSha":"16bc6e0711a4945be17e8bc4bc7ccf9469f3fdec","analyzedAt":"2026-08-13T19:57:05.828Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}