cefsharp/CefSharp · error · Exception

The ChromiumWebBrowser instance creates the underlying Chrom

Error message

The ChromiumWebBrowser instance creates the underlying Chromium Embedded Framework (CEF) browser instance in an async fashion. The undelying CefBrowser instance is not yet initialized. Use the IsBrowserInitializedChanged event and check the IsBrowserInitialized property to determine when the browser has been initialized.

What it means

Thrown by ThrowExceptionIfBrowserNotInitialized when a member that requires the underlying CefBrowser is accessed before the browser has finished its async initialization. ChromiumWebBrowser creates the CEF browser asynchronously, so accessing browser-dependent APIs immediately after construction fails. The message directs you to the IsBrowserInitializedChanged event and IsBrowserInitialized property.

Source

Thrown at CefSharp/Internals/Partial/ChromiumWebBrowser.Partial.cs:555

        /// Check is browser is initialized
        /// </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>
        /// Throw exception if browser not initialized.
        /// </summary>
        /// <exception cref="Exception">Thrown when an exception error condition occurs.</exception>
        private void ThrowExceptionIfBrowserNotInitialized()
        {
            if (!InternalIsBrowserInitialized())
            {
                throw new Exception(BrowserNotInitializedExceptionErrorMessage);
            }
        }

        /// <summary>
        /// Throw exception if disposed.
        /// </summary>
        /// <exception cref="ObjectDisposedException">Thrown when a supplied object has been disposed.</exception>
        private void ThrowExceptionIfDisposed()
        {
            if (IsDisposed)
            {
                throw new ObjectDisposedException("ChromiumWebBrowser");
            }
        }

        private int GetChromiumChildProcessId(string frameIdentifier)
        {
            try

View on GitHub (pinned to 16bc6e0711)

Solutions

  1. Subscribe to IsBrowserInitializedChanged and perform browser-dependent work only when IsBrowserInitialized is true.
  2. Await the appropriate initialization task/awaitable your ChromiumWebBrowser host exposes before calling browser APIs.
  3. For OffScreen, await the initialization completion before loading content.
  4. Move Load/exec calls into an initialized callback rather than the constructor.

Example fix

// before
var browser = new ChromiumWebBrowser(url);
browser.ExecuteScriptAsync("doStuff()"); // not initialized yet

// after
var browser = new ChromiumWebBrowser(url);
browser.IsBrowserInitializedChanged += (s, e) =>
{
    if (browser.IsBrowserInitialized)
        browser.ExecuteScriptAsync("doStuff()");
};
Defensive patterns

Strategy: validation

Validate before calling

if (!browser.IsBrowserInitialized)
{
    var tcs = new TaskCompletionSource<bool>();
    browser.IsBrowserInitializedChanged += (s, e) =>
    {
        if (browser.IsBrowserInitialized) tcs.TrySetResult(true);
    };
    await tcs.Task;
}
// browser is now ready

Try / catch

try { browser.Load(url); }
catch (Exception ex) when (ex.Message.Contains("not yet initialized"))
{ /* wait for IsBrowserInitialized, then retry once */ }

Prevention

When it happens

Trigger: Calling Load(), GetBrowser(), ExecuteScriptAsync(), or similar immediately after `new ChromiumWebBrowser(...)` in the same synchronous block, before IsBrowserInitialized becomes true.

Common situations: Constructing the browser and calling Load in the same constructor/Loaded handler; headless (OffScreen) usage that does not wait for initialization; tests that act on the browser too early.

Related errors


AI-assisted analysis of cefsharp/CefSharp@16bc6e0711 (2026-08-13). Data as JSON: /api/errors/fe50e9fa3cfbffe9. Report an issue: GitHub.