{"record":{"id":"653a688b6cbf45dd","repo":"cefsharp/CefSharp","slug":"cef-isinitialized-was-false-check-the-log-file-fo-653a68","errorCode":null,"errorMessage":"Cef.IsInitialized was false!.Check the log file for errors!. See https://github.com/cefsharp/CefSharp/wiki/Trouble-Shooting#log-file for details.","messagePattern":"Cef\\.IsInitialized was false!\\.Check the log file for errors!\\. See https://github\\.com/cefsharp/CefSharp/wiki/Trouble-Shooting#log-file for details\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"critical","filePath":"CefSharp/Internals/Partial/ChromiumWebBrowser.Partial.cs","lineNumber":532,"sourceCode":"            ResourceRequestHandlerFactory = null;\n            RenderProcessMessageHandler = null;\n\n            this.FreeDevToolsContext();\n        }\n\n        private static void InitializeCefInternal()\n        {\n            if (Cef.IsInitialized == null)\n            {\n                if (!Cef.Initialize(new CefSettings()))\n                {\n                    throw new InvalidOperationException(CefInitializeFailedErrorMessage);\n                }\n            }\n\n            if (Cef.IsInitialized == false)\n            {\n                throw new InvalidOperationException(CefIsInitializedFalseErrorMessage);\n            }\n        }\n\n        /// <summary>\n        /// Check is browser is initialized\n        /// </summary>\n        /// <returns>true if browser is initialized</returns>\n        private bool InternalIsBrowserInitialized()\n        {\n            // Use CompareExchange to read the current value - if disposeCount is 1, we set it to 1, effectively a no-op\n            // Volatile.Read would likely use a memory barrier which I believe is unnecessary in this scenario\n            return Interlocked.CompareExchange(ref browserInitialized, 0, 0) == 1;\n        }\n\n        /// <summary>\n        /// Throw exception if browser not initialized.\n        /// </summary>\n        /// <exception cref=\"Exception\">Thrown when an exception error condition occurs.</exception>","sourceCodeStart":514,"sourceCodeEnd":550,"githubUrl":"https://github.com/cefsharp/CefSharp/blob/16bc6e0711a4945be17e8bc4bc7ccf9469f3fdec/CefSharp/Internals/Partial/ChromiumWebBrowser.Partial.cs#L514-L550","documentation":"Thrown by InitializeCefInternal when Cef.IsInitialized is explicitly false (not null). This means CEF was initialized at some point and is no longer initialized, typically because Cef.Shutdown() was already called. Re-initializing CEF after shutdown is not supported, so the boolean false is treated as a hard failure.","triggerScenarios":"Calling code that constructs a ChromiumWebBrowser (which triggers InitializeCefInternal) after Cef.Shutdown() has run; app shutdown ordering issues where a browser is created during teardown; a second CEF lifecycle in the same process.","commonSituations":"Hot-reload/restart logic that shuts CEF down and tries to bring it back; disposal ordering where a late-created browser references a shut-down CEF; test runner reusing a process across fixtures that call Shutdown.","solutions":["Do not create ChromiumWebBrowser instances after Cef.Shutdown(); keep a single CEF lifecycle for the process.","Fix shutdown ordering so all browsers are disposed before Cef.Shutdown().","For restart scenarios, run CEF in a separate process you can relaunch instead of re-initializing in-process.","Guard browser creation with a check that Cef.IsInitialized is not false before constructing."],"exampleFix":"// before\nCef.Shutdown();\nvar b = new ChromiumWebBrowser(url); // IsInitialized now false -> throws\n\n// after\n// keep CEF alive for the whole process; dispose all browsers, then call Shutdown only once at app exit.","handlingStrategy":"validation","validationCode":"if (Cef.IsInitialized == false)\n    throw new InvalidOperationException(\"CEF has been shut down; cannot create a new browser in this process.\");\n// Only construct browsers while CEF is alive:\nvar browser = new ChromiumWebBrowser(url);","typeGuard":null,"tryCatchPattern":"try { var browser = new ChromiumWebBrowser(url); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"Cef.IsInitialized was false\"))\n{ /* do not retry; CEF must be restarted in a fresh process */ }","preventionTips":["Call Cef.Shutdown() exactly once at process exit, after all browsers are disposed.","Never create browsers after shutdown.","Use a separate process for restart/reload scenarios."],"tags":["cefsharp","cef-initialization","lifecycle","shutdown","startup"],"backgroundTag":null,"analyzedSha":"16bc6e0711a4945be17e8bc4bc7ccf9469f3fdec","analyzedAt":"2026-08-13T19:57:05.828Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}