cefsharp/CefSharp · error · InvalidOperationException

Property {0} not found on Object of Type {1}

Error message

Property {0} not found on Object of Type {1}

What it means

Thrown by TryGetProperty (the getter path) when the bound object was found via objectId but no property has a JavascriptName matching the requested name. As with the methods, the object-not-found case returns false without throwing, while a property-name mismatch raises InvalidOperationException. The message prints the requested property name and the object's runtime type.

Source

Thrown at CefSharp/Internals/JavascriptObjectRepository.cs:589

        bool IJavascriptObjectRepositoryInternal.TryGetProperty(long objectId, string name, out object result, out string exception)
        {
            return TryGetProperty(objectId, name, out result, out exception);
        }

        protected virtual bool TryGetProperty(long objectId, string name, out object result, out string exception)
        {
            exception = "";
            result = null;
            JavascriptObject obj;
            if (!objects.TryGetValue(objectId, out obj))
            {
                return false;
            }

            var property = obj.Properties.FirstOrDefault(p => p.JavascriptName == name);
            if (property == null)
            {
                throw new InvalidOperationException(string.Format("Property {0} not found on Object of Type {1}", name, obj.Value.GetType()));
            }

            try
            {
                if (obj.PropertyInterceptor == null)
                {
                    result = property.GetValue(obj.Value);
                }
                else
                {
                    result = obj.PropertyInterceptor.InterceptGet(() => property.GetValue(obj.Value), property.ManagedName);
                }
                return true;
            }
            catch (Exception ex)
            {
                exception = ex.ToString();
            }

View on GitHub (pinned to 16bc6e0711)

Solutions

  1. Read the property by its JavaScript (camelCase) name.
  2. Confirm the property is in obj.Properties and not excluded by BindingOptions.
  3. Regenerate JS/TS bindings after C# property renames.
  4. Audit binding options that restrict which properties are exposed.

Example fix

// C#: public string UserName { get; set; } -> JS name "userName"
// before (JS): const n = obj.username; // typo/wrong casing
// after  (JS): const n = obj.userName;
Defensive patterns

Strategy: validation

Validate before calling

var exposedProps = obj.Properties.Select(p => p.JavascriptName);
if (!exposedProps.Contains(jsPropName, StringComparer.Ordinal))
    throw new InvalidOperationException($"Property {jsPropName} not exposed.");

Try / catch

try { repository.TryGetProperty(objectId, name, out value, out ex); }
catch (InvalidOperationException ex) when (ex.Message.Contains("Property") && ex.Message.Contains("not found"))
{ /* property name mismatch from JS */ }

Prevention

When it happens

Trigger: JavaScript reads a property by a name that does not exist on the bound object (typo, casing, or property filtered out by BindingOptions); reading a property on the wrong object id.

Common situations: Renaming a C# property and not updating JS; relying on the managed name instead of the camelCase JS name; property excluded from binding; stale generated contract.

Related errors


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