cefsharp/CefSharp · error · ArgumentNullException
name
Error message
name
What it means
Thrown by JavascriptObjectRepository.Register when the name argument is null. The name is the JavaScript global object key under which the bound .NET object is exposed to the page; a null name cannot be registered, so Register fails fast with ArgumentNullException before touching the object table. Register then calls Freeze() and performs further validation.
Source
Thrown at CefSharp/Internals/JavascriptObjectRepository.cs:205
{
Id = id,
RootObject = rootObject
};
objects[id] = result;
return result;
}
#if NETCOREAPP
public void Register(string name, object value, BindingOptions options)
#else
public void Register(string name, object value, bool isAsync, BindingOptions options)
#endif
{
if (name == null)
{
throw new ArgumentNullException("name");
}
if (value == null)
{
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;
}View on GitHub (pinned to 16bc6e0711)
Solutions
- Ensure the name is a non-null, non-empty, unique string before calling Register.
- Validate names from dynamic sources (metadata/dictionary) and skip or default null entries.
- Check uniqueness against already-bound names since a later check throws ArgumentException on duplicates.
Example fix
// before
repo.Register(name, myObject, new BindingOptions());
// after
if (string.IsNullOrEmpty(name)) throw new ArgumentException("Binding name required.");
repo.Register(name, myObject, new BindingOptions()); Defensive patterns
Strategy: validation
Validate before calling
if (string.IsNullOrEmpty(name))
{
throw new ArgumentException("Binding name is required.");
}
repo.Register(name, value, new BindingOptions()); Type guard
static bool IsValidBindingName(string name) => !string.IsNullOrEmpty(name);
Prevention
- Validate binding names (non-null, non-empty, unique) before Register.
- Filter null names from dynamic/metadata-driven binding loops.
- Register all objects before browser creation to also avoid the freeze path.
When it happens
Trigger: Calling browser.JavascriptObjectRepository.Register(null, obj, ...) or the BindingOptions overload with a name variable that was never assigned. Common in dynamic binding loops where the name comes from a dictionary/metadata source that yielded null.
Common situations: Binding objects in a loop driven by external metadata where a name field is missing; a config-driven binding list with an empty key; copy-paste that dropped the name argument; DI resolving a name that returned null.
Related errors
AI-assisted analysis of cefsharp/CefSharp@16bc6e0711 (2026-08-13).
Data as JSON: /api/errors/c380fe2b1790a534.
Report an issue: GitHub.