cefsharp/CefSharp · error · InvalidOperationException
Method {0} not found on Object of Type {1}
Error message
Method {0} not found on Object of Type {1} What it means
Thrown by the SYNCHRONOUS TryCallMethod path when the bound object was found (its objectId resolved) but no method on it has a JavascriptName matching the requested name. The earlier 'object not found' case returns a TryCallMethodResult instead of throwing, but a name mismatch here raises InvalidOperationException. method.JavascriptName is the camelCased name exposed to JavaScript.
Source
Thrown at CefSharp/Internals/JavascriptObjectRepository.cs:304
}
protected virtual TryCallMethodResult TryCallMethod(long objectId, string name, object[] parameters)
{
var exception = "";
object result = null;
JavascriptObject obj;
if (!objects.TryGetValue(objectId, out obj))
{
var paramCount = parameters == null ? 0 : parameters.Length;
return new TryCallMethodResult(false, result, $"Object Not Found Matching Id:{objectId}, MethodName:{name}, ParamCount:{paramCount}");
}
var method = obj.Methods.FirstOrDefault(p => p.JavascriptName == name);
if (method == null)
{
throw new InvalidOperationException(string.Format("Method {0} not found on Object of Type {1}", name, obj.Value.GetType()));
}
try
{
//Check if the bound object method contains a ParamArray as the last parameter on the method signature.
//NOTE: No additional parameters are permitted after the params keyword in a method declaration,
//and only one params keyword is permitted in a method declaration.
//https://msdn.microsoft.com/en-AU/library/w5zay9db.aspx
if (method.HasParamArray)
{
var paramList = new List<object>(method.Parameters.Count);
//Loop through all of the method parameters on the bound object.
for (var i = 0; i < method.Parameters.Count; i++)
{
//If the method parameter is a paramArray IE: (params string[] args)
//grab the parameters from the javascript function starting at the current bound object parameter index
//and add create an array that will be passed in as the last bound object method parameter.View on GitHub (pinned to 16bc6e0711)
Solutions
- Call the method by its JavaScript (camelCase) name, not the C# PascalCase name.
- Verify the method exists on the bound object and is included by your BindingOptions.
- Inspect obj.Methods to see the exposed JavascriptName values and match them exactly.
- Keep C# method names stable or regenerate the TS/JS contract after renames.
Example fix
// C#: public void DoWork() -> JS name "doWork" // before (JS): cefSharp bonded obj.doWorkSync(); // wrong name // after (JS): await obj.doWork();
Defensive patterns
Strategy: validation
Validate before calling
var exposed = obj.Methods.Select(m => m.JavascriptName);
if (!exposed.Contains(jsMethodName, StringComparer.Ordinal))
throw new InvalidOperationException($"Method {jsMethodName} not exposed. Known: {string.Join(", ", exposed)}"); Try / catch
try { repository.TryCallMethod(...); }
catch (InvalidOperationException ex) when (ex.Message.Contains("Method") && ex.Message.Contains("not found"))
{ /* unknown method name from JS; log and ignore */ } Prevention
- Always call methods by their camelCase JavaScript name.
- Keep JS/TS contracts regenerated after C# renames.
- Inspect obj.Methods to confirm exposed names.
When it happens
Trigger: JavaScript calls a bound method by a name that does not exist (typo, wrong casing, or a method that was filtered out by binding options); calling a method on the wrong object id; method was renamed on the C# side but JS still uses the old name.
Common situations: Renaming a C# method and forgetting to update JS; relying on the managed name instead of the javascript (camelCase) name; binding options excluding the method; interop name mangling differences.
Related errors
- Could not execute method: {name}({parameters}) {optional: -
- Property {0} not found on Object of Type {1}
- name
- value
- To enable synchronous JS bindings set WcfEnabled true in Cef
AI-assisted analysis of cefsharp/CefSharp@16bc6e0711 (2026-08-13).
Data as JSON: /api/errors/bcaea8dfa727342a.
Report an issue: GitHub.