cefsharp/CefSharp · critical · InvalidOperationException
Cef.IsInitialized was false!.Check the log file for errors!.
Error message
Cef.IsInitialized was false!.Check the log file for errors!. See https://github.com/cefsharp/CefSharp/wiki/Trouble-Shooting#log-file for details.
What it means
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.
Source
Thrown at CefSharp.Wpf/HwndHost/ChromiumWebBrowser.cs:1730
/// <returns>browser instance or null</returns>
public IBrowser GetBrowser()
{
return browser;
}
private static void InitializeCefInternal()
{
if (Cef.IsInitialized == null)
{
if (!Cef.Initialize(new CefSettings()))
{
throw new InvalidOperationException(CefInitializeFailedErrorMessage);
}
}
if (Cef.IsInitialized == false)
{
throw new InvalidOperationException(CefIsInitializedFalseErrorMessage);
}
}
/// <summary>
/// Check is browserisinitialized
/// </summary>
/// <returns>true if browser is initialized</returns>
private bool InternalIsBrowserInitialized()
{
// Use CompareExchange to read the current value - if disposeCount is 1, we set it to 1, effectively a no-op
// Volatile.Read would likely use a memory barrier which I believe is unnecessary in this scenario
return Interlocked.CompareExchange(ref browserInitialized, 0, 0) == 1;
}
/// <summary>
/// Resizes the browser.
/// </summary>
private void ResizeBrowser(int width, int height)View on GitHub (pinned to 16bc6e0711)
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.
Example fix
// before — init called again after shutdown Cef.Shutdown(); var browser = new ChromiumWebBrowser(); // triggers InitializeCefInternal -> throws // after — do not create browsers after shutdown Cef.Shutdown(); // application is exiting; no further browser creation
Defensive patterns
Strategy: validation
Validate before calling
if (Cef.IsInitialized == false)
{
throw new InvalidOperationException(
"CEF is in an invalid state (IsInitialized=false). " +
"Likely already shut down. Cannot reinitialize.");
}
if (Cef.IsInitialized == null)
{
Cef.Initialize(settings);
}
// now safe to create browsers Try / catch
try
{
var browser = new ChromiumWebBrowser();
}
catch (InvalidOperationException ex) when (ex.Message.Contains("Cef.IsInitialized was false"))
{
Log.Error("CEF was shut down — cannot create browser. Restart the process.", ex);
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Cef.IsInitialized was false!.Check the log file for errors!.
- Cef.Initialize() failed.Check the log file see https://githu
- Unable to Initialize Cef
- Browser has already been created. BrowserSettings must be se
- Browser has already been created. RequestContext must be set
AI-assisted analysis of cefsharp/CefSharp@16bc6e0711 (2026-08-13).
Data as JSON: /api/errors/3c69df8bdc74873e.
Report an issue: GitHub.