{"record":{"id":"bcaea8dfa727342a","repo":"cefsharp/CefSharp","slug":"method-0-not-found-on-object-of-type-1","errorCode":null,"errorMessage":"Method {0} not found on Object of Type {1}","messagePattern":"Method (.+?) not found on Object of Type (.+?)","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"CefSharp/Internals/JavascriptObjectRepository.cs","lineNumber":304,"sourceCode":"        }\n\n        protected virtual TryCallMethodResult TryCallMethod(long objectId, string name, object[] parameters)\n        {\n            var exception = \"\";\n            object result = null;\n            JavascriptObject obj;\n\n            if (!objects.TryGetValue(objectId, out obj))\n            {\n                var paramCount = parameters == null ? 0 : parameters.Length;\n\n                return new TryCallMethodResult(false, result, $\"Object Not Found Matching Id:{objectId}, MethodName:{name}, ParamCount:{paramCount}\");\n            }\n\n            var method = obj.Methods.FirstOrDefault(p => p.JavascriptName == name);\n            if (method == null)\n            {\n                throw new InvalidOperationException(string.Format(\"Method {0} not found on Object of Type {1}\", name, obj.Value.GetType()));\n            }\n\n            try\n            {\n                //Check if the bound object method contains a ParamArray as the last parameter on the method signature.\n                //NOTE: No additional parameters are permitted after the params keyword in a method declaration,\n                //and only one params keyword is permitted in a method declaration.\n                //https://msdn.microsoft.com/en-AU/library/w5zay9db.aspx\n                if (method.HasParamArray)\n                {\n                    var paramList = new List<object>(method.Parameters.Count);\n\n                    //Loop through all of the method parameters on the bound object.\n                    for (var i = 0; i < method.Parameters.Count; i++)\n                    {\n                        //If the method parameter is a paramArray IE: (params string[] args)\n                        //grab the parameters from the javascript function starting at the current bound object parameter index\n                        //and add create an array that will be passed in as the last bound object method parameter.","sourceCodeStart":286,"sourceCodeEnd":322,"githubUrl":"https://github.com/cefsharp/CefSharp/blob/16bc6e0711a4945be17e8bc4bc7ccf9469f3fdec/CefSharp/Internals/JavascriptObjectRepository.cs#L286-L322","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// C#: public void DoWork()  ->  JS name \"doWork\"\n// before (JS): cefSharp bonded obj.doWorkSync(); // wrong name\n// after  (JS): await obj.doWork();","handlingStrategy":"validation","validationCode":"var exposed = obj.Methods.Select(m => m.JavascriptName);\nif (!exposed.Contains(jsMethodName, StringComparer.Ordinal))\n    throw new InvalidOperationException($\"Method {jsMethodName} not exposed. Known: {string.Join(\", \", exposed)}\");","typeGuard":null,"tryCatchPattern":"try { repository.TryCallMethod(...); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"Method\") && ex.Message.Contains(\"not found\"))\n{ /* unknown method name from JS; log and ignore */ }","preventionTips":["Always call methods by their camelCase JavaScript name.","Keep JS/TS contracts regenerated after C# renames.","Inspect obj.Methods to confirm exposed names."],"tags":["cefsharp","javascript-binding","method-not-found","interop-naming","sync"],"backgroundTag":null,"analyzedSha":"16bc6e0711a4945be17e8bc4bc7ccf9469f3fdec","analyzedAt":"2026-08-13T19:57:05.828Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}