{"record":{"id":"d06258d57fcf4f2c","repo":"cefsharp/CefSharp","slug":"invalid-or-illegal-characters-used-for-binding-pro","errorCode":null,"errorMessage":"invalid or illegal characters used for binding property names. Alphanumeric and underscores characters only.","messagePattern":"invalid or illegal characters used for binding property names\\. Alphanumeric and underscores characters only\\.","errorType":"validation","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"CefSharp/JavascriptBinding/JavascriptBindingSettings.cs","lineNumber":88,"sourceCode":"        /// be created e.g. cefSharp.bindObjectAsync, CefSharp.BindObjectAsync.\n        /// If specified then your custom name will be used, if the name starts with a lowercase letter\n        /// then all the functions will be lowercase, e.g. myObjName.bindObjectAsync otherwise\n        /// the functions will start with a uppercase letter e.g. MyObjName.BindObjectAsync\n        /// </summary>\n        /// <remarks>\n        /// This object is also accessible through the window property. e.g. window.cefSharp.bindObjectAsync\n        /// </remarks>\n        public string JavascriptBindingApiGlobalObjectName\n        {\n            get { return jsBindingGlobalObjectName; }\n            set\n            {\n                ThrowIfFrozen();\n\n                if (!StringCheck.IsLettersAndNumbers(value))\n                {\n                    //TODO: See if there's a better suited Exception class for this.\n                    throw new System.Exception(\"invalid or illegal characters used for binding property names. Alphanumeric and underscores characters only.\");\n                }\n\n                jsBindingGlobalObjectName = value;\n            }\n        }\n\n        /// <summary>\n        /// Objects registered using <see cref=\"IJavascriptObjectRepository.Register\"/>\n        /// will be automatically bound when a V8Context is created. (Soon as the Javascript\n        /// context is created for a browser). This behaviour is like that seen with Javascript\n        /// Binding in version 57 and earlier.\n        /// </summary>\n        public bool LegacyBindingEnabled\n        {\n            get { return legacyBindingEnabled; }\n            set\n            {\n                ThrowIfFrozen();","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/cefsharp/CefSharp/blob/16bc6e0711a4945be17e8bc4bc7ccf9469f3fdec/CefSharp/JavascriptBinding/JavascriptBindingSettings.cs#L70-L106","documentation":"Thrown by the JavascriptBindingApiGlobalObjectName setter when the proposed name fails StringCheck.IsLettersAndNumbers, which requires a non-empty/non-whitespace string matching ^\\w+$ (letters, digits, underscore only). This name becomes a global/window property in JavaScript, so it must be a valid identifier without dots, dashes, spaces, or symbols.","triggerScenarios":"Setting JavascriptBindingApiGlobalObjectName to a value containing dots (e.g. 'my.api'), dashes, spaces, a path, an empty string, or null.","commonSituations":"Trying to namespace the global object with a dotted path; copying a name from a URL or config with disallowed characters; passing whitespace by accident.","solutions":["Use a single alphanumeric/underscore identifier (e.g. 'cefSharp', 'myApp').","Validate the value with a ^\\w+$ check before assigning.","Call ThrowIfFrozen-style guards earlier if the settings are already in use.","Keep the default if you do not need a custom global name."],"exampleFix":"// before\nsettings.JavascriptBindingApiGlobalObjectName = \"my.api\"; // dot not allowed\n\n// after\nsettings.JavascriptBindingApiGlobalObjectName = \"myApi\";","handlingStrategy":"validation","validationCode":"static bool IsValidGlobalName(string s) =>\n    !string.IsNullOrWhiteSpace(s) && System.Text.RegularExpressions.Regex.IsMatch(s, @\"^\\w+$\");\nif (IsValidGlobalName(name)) settings.JavascriptBindingApiGlobalObjectName = name;","typeGuard":"static bool IsValidGlobalName(string s) =>\n    !string.IsNullOrWhiteSpace(s) && System.Text.RegularExpressions.Regex.IsMatch(s, @\"^\\w+$\");","tryCatchPattern":"try { settings.JavascriptBindingApiGlobalObjectName = name; }\ncatch (Exception ex) when (ex.Message.Contains(\"invalid or illegal characters\"))\n{ settings.JavascriptBindingApiGlobalObjectName = \"cefSharp\"; /* fallback */ }","preventionTips":["Use a plain alphanumeric/underscore identifier.","Avoid dotted namespaced paths.","Keep the default unless you need a custom global."],"tags":["cefsharp","javascript-binding","configuration","naming","validation"],"backgroundTag":null,"analyzedSha":"16bc6e0711a4945be17e8bc4bc7ccf9469f3fdec","analyzedAt":"2026-08-13T19:57:05.828Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}