{"record":{"id":"c380fe2b1790a534","repo":"cefsharp/CefSharp","slug":"name","errorCode":null,"errorMessage":"name","messagePattern":"name","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"CefSharp/Internals/JavascriptObjectRepository.cs","lineNumber":205,"sourceCode":"            {\n                Id = id,\n                RootObject = rootObject\n            };\n\n            objects[id] = result;\n\n            return result;\n        }\n\n#if NETCOREAPP\n        public void Register(string name, object value, BindingOptions options)\n#else\n        public void Register(string name, object value, bool isAsync, BindingOptions options)\n#endif\n        {\n            if (name == null)\n            {\n                throw new ArgumentNullException(\"name\");\n            }\n\n            if (value == null)\n            {\n                throw new ArgumentNullException(\"value\");\n            }\n\n            Freeze();\n\n            //Enable WCF if not already enabled - can only be done before the browser has been initliazed\n            //if done after the subprocess won't be WCF enabled it we'll have to throw an exception\n#if NETCOREAPP\n            var isAsync = true;\n#else\n            if (!IsBrowserInitialized && !isAsync)\n            {\n                CefSharpSettings.WcfEnabled = true;\n            }","sourceCodeStart":187,"sourceCodeEnd":223,"githubUrl":"https://github.com/cefsharp/CefSharp/blob/16bc6e0711a4945be17e8bc4bc7ccf9469f3fdec/CefSharp/Internals/JavascriptObjectRepository.cs#L187-L223","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nrepo.Register(name, myObject, new BindingOptions());\n\n// after\nif (string.IsNullOrEmpty(name)) throw new ArgumentException(\"Binding name required.\");\nrepo.Register(name, myObject, new BindingOptions());","handlingStrategy":"validation","validationCode":"if (string.IsNullOrEmpty(name))\n{\n    throw new ArgumentException(\"Binding name is required.\");\n}\nrepo.Register(name, value, new BindingOptions());","typeGuard":"static bool IsValidBindingName(string name) => !string.IsNullOrEmpty(name);","tryCatchPattern":null,"preventionTips":["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."],"tags":["javascript-binding","validation","null-reference","registration","cefsharp"],"backgroundTag":null,"analyzedSha":"16bc6e0711a4945be17e8bc4bc7ccf9469f3fdec","analyzedAt":"2026-08-13T19:57:05.828Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}