{"record":{"id":"3c69df8bdc74873e","repo":"cefsharp/CefSharp","slug":"cef-isinitialized-was-false-check-the-log-file-fo","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.Wpf/HwndHost/ChromiumWebBrowser.cs","lineNumber":1730,"sourceCode":"        /// <returns>browser instance or null</returns>\n        public IBrowser GetBrowser()\n        {\n            return browser;\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 browserisinitialized\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        /// Resizes the browser.\n        /// </summary>\n        private void ResizeBrowser(int width, int height)","sourceCodeStart":1712,"sourceCodeEnd":1748,"githubUrl":"https://github.com/cefsharp/CefSharp/blob/16bc6e0711a4945be17e8bc4bc7ccf9469f3fdec/CefSharp.Wpf/HwndHost/ChromiumWebBrowser.cs#L1712-L1748","documentation":"After initialization, Cef.IsInitialized is checked again. A value of false (not null) means CEF was initialized at some earlier point but is no longer in a valid state — most likely Cef.Shutdown was called, or a secondary AppDomain is involved where CEF cannot reinitialize.","triggerScenarios":"Calling InitializeCefInternal after Cef.Shutdown has run. Creating a ChromiumWebBrowser in a new AppDomain after the first one shut CEF down. A crash during a previous Cef.Initialize that left IsInitialized as false.","commonSituations":"Hot-reload or plugin scenarios where the host shuts down and restarts CEF. Unit test runners that create and tear down AppDomains. Application shutdown followed by a late-arriving browser creation request.","solutions":["Ensure Cef.Shutdown is only called at true application exit and no browsers are created afterward.","In test or plugin hosts, keep CEF initialized for the lifetime of the process rather than per-session init/shutdown cycles.","Check Cef.IsInitialized before creating any browser and skip re-initialization if it is already true.","Inspect debug.log for the original shutdown or crash that left CEF in a false state."],"exampleFix":"// before — init called again after shutdown\nCef.Shutdown();\nvar browser = new ChromiumWebBrowser(); // triggers InitializeCefInternal -> throws\n\n// after — do not create browsers after shutdown\nCef.Shutdown();\n// application is exiting; no further browser creation","handlingStrategy":"validation","validationCode":"if (Cef.IsInitialized == false)\n{\n    throw new InvalidOperationException(\n        \"CEF is in an invalid state (IsInitialized=false). \" +\n        \"Likely already shut down. Cannot reinitialize.\");\n}\nif (Cef.IsInitialized == null)\n{\n    Cef.Initialize(settings);\n}\n// now safe to create browsers","typeGuard":null,"tryCatchPattern":"try\n{\n    var browser = new ChromiumWebBrowser();\n}\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"Cef.IsInitialized was false\"))\n{\n    Log.Error(\"CEF was shut down — cannot create browser. Restart the process.\", ex);\n}","preventionTips":["Call Cef.Shutdown only at true application exit.","Never create browsers after shutdown.","In test runners, initialize CEF once per process, not per test fixture."],"tags":["cef-initialization","lifecycle","shutdown","startup","wpf-hwndhost"],"backgroundTag":null,"analyzedSha":"16bc6e0711a4945be17e8bc4bc7ccf9469f3fdec","analyzedAt":"2026-08-13T19:57:05.828Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}