cefsharp/CefSharp · error · InvalidOperationException
To enable synchronous JS bindings set WcfEnabled true in Cef
Error message
To enable synchronous JS bindings set WcfEnabled true in CefSharpSettings before you create your ChromiumWebBrowser instances.
What it means
Thrown when a .NET Framework (non-NETCOREAPP) build tries to register a SYNCHRONOUS JavaScript binding (isAsync == false) while CefSharpSettings.WcfEnabled is false AND the browser is already initialized. On the full-framework build the repo auto-sets WcfEnabled=true only if IsBrowserInitialized is false, so the guard exists because the WCF subprocess cannot be enabled after the browser has started. NETCOREAPP builds force isAsync=true and never hit this path.
Source
Thrown at CefSharp/Internals/JavascriptObjectRepository.cs:227
{
throw new ArgumentNullException("value");
}
Freeze();
//Enable WCF if not already enabled - can only be done before the browser has been initliazed
//if done after the subprocess won't be WCF enabled it we'll have to throw an exception
#if NETCOREAPP
var isAsync = true;
#else
if (!IsBrowserInitialized && !isAsync)
{
CefSharpSettings.WcfEnabled = true;
}
if (!CefSharpSettings.WcfEnabled && !isAsync)
{
throw new InvalidOperationException(@"To enable synchronous JS bindings set WcfEnabled true in CefSharpSettings before you create
your ChromiumWebBrowser instances.");
}
#endif
//Validation name is unique
if (objects.Values.Count(x => string.Equals(x.Name, name, StringComparison.OrdinalIgnoreCase)) > 0)
{
throw new ArgumentException("Object already bound with name:" + name, name);
}
//Binding of System types is problematic, so we don't support it
var type = value.GetType();
if (type.IsPrimitive || type.BaseType.Namespace.StartsWith("System."))
{
throw new ArgumentException("Registering of .Net framework built in types is not supported, " +
"create your own Object and proxy the calls if you need to access a Window/Form/Control.", "value");
}
View on GitHub (pinned to 16bc6e0711)
Solutions
- Set CefSharpSettings.WcfEnabled = true once at startup, before any ChromiumWebBrowser instance is constructed.
- Register your bound objects before the browser is initialized (move the Register call ahead of browser creation).
- Switch to async bindings (RegisterAsync / IsAsync = true), which do not require WCF and are the only mode supported on .NET Core.
- If you must keep sync bindings on .NET Framework, ensure no ChromiumWebBrowser is created before CefSharpSettings.WcfEnabled = true runs.
Example fix
// before
var browser = new ChromiumWebBrowser("https://example.com");
repository.Register("myObj", new MyObj(), isAsync: false);
// after
CefSharpSettings.WcfEnabled = true; // before ANY ChromiumWebBrowser is created
var browser = new ChromiumWebBrowser("https://example.com");
repository.Register("myObj", new MyObj(), isAsync: false); Defensive patterns
Strategy: validation
Validate before calling
// Run once at startup, before any ChromiumWebBrowser is created: CefSharpSettings.WcfEnabled = true; // Prefer async registration on all targets: await repository.RegisterAsync(...); // avoids the WCF requirement entirely
Type guard
if (CefSharpSettings.WcfEnabled && !isAsync) { /* sync binding is safe */ } Prevention
- Set CefSharpSettings.WcfEnabled at the very start of Main/Startup, before UI construction.
- Prefer async bindings (RegisterAsync) which need no WCF and work on .NET Core.
- Keep all Register calls ahead of ChromiumWebBrowser creation on the framework build.
When it happens
Trigger: Calling IJavascriptObjectRepository.Register(...) with synchronous binding semantics on the .NET Framework build after a ChromiumWebBrowser has already been created and its underlying browser initialized, without first setting CefSharpSettings.WcfEnabled = true.
Common situations: App constructs the ChromiumWebBrowser early (e.g. in a Window/Form constructor or Loaded handler) and only registers bound objects later in response to a user action; migrating from a version that defaulted WcfEnabled true; or using Register instead of RegisterAsync on the framework build.
Related errors
- invalid or illegal characters used for binding property name
- converter
- {GetType().Name}.{memberName} can no longer be modified, set
- name
- value
AI-assisted analysis of cefsharp/CefSharp@16bc6e0711 (2026-08-13).
Data as JSON: /api/errors/88fac6023a68d402.
Report an issue: GitHub.