{"record":{"id":"53be024952207c3d","repo":"dotnet/maui","slug":"key","errorCode":null,"errorMessage":"key","messagePattern":"key","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"src/Controls/src/Core/BindableObject.cs","lineNumber":493,"sourceCode":"\n\t\t\tOnRemoveDynamicResource(property);\n\t\t\tBindablePropertyContext context = GetOrCreateContext(property);\n\t\t\tcontext.Attributes &= ~BindableContextAttributes.IsDynamicResource;\n\t\t}\n\n\t\tvoid IDynamicResourceHandler.SetDynamicResource(BindableProperty property, string key)\n\t\t\t=> SetDynamicResource(property, key, SetterSpecificity.DynamicResourceSetter);\n\n\t\tinternal void SetDynamicResource(BindableProperty property, string key)\n\t\t\t=> SetDynamicResource(property, key, SetterSpecificity.DynamicResourceSetter);\n\n\t\t//FIXME, use specificity\n\t\tinternal void SetDynamicResource(BindableProperty property, string key, SetterSpecificity specificity)\n\t\t{\n\t\t\tif (property == null)\n\t\t\t\tthrow new ArgumentNullException(nameof(property));\n\t\t\tif (string.IsNullOrEmpty(key))\n\t\t\t\tthrow new ArgumentNullException(nameof(key));\n\n\t\t\tOnSetDynamicResource(property, key, specificity);\n\t\t}\n\n\t\t/// <summary>\n\t\t/// Sets the value of the specified bindable property.\n\t\t/// </summary>\n\t\t/// <param name=\"property\">The bindable property on which to assign a value.</param>\n\t\t/// <param name=\"value\">The value to set.</param>\n\t\t/// <exception cref=\"ArgumentNullException\">Thrown when <paramref name=\"property\"/> is <see langword=\"null\"/>.</exception>\n\t\t/// <remarks>If <paramref name=\"property\"/> is read-only, nothing will happen.</remarks>\n\t\tpublic void SetValue(BindableProperty property, object value)\n\t\t{\n\t\t\tif (property == null)\n\t\t\t\tthrow new ArgumentNullException(nameof(property));\n\n\t\t\tif (value is BindingBase binding && !property.ReturnType.IsAssignableFrom(typeof(BindingBase)))\n\t\t\t{","sourceCodeStart":475,"sourceCodeEnd":511,"githubUrl":"https://github.com/dotnet/maui/blob/f377ff1c5ee04d334d8a925f50c83a6b7afddf03/src/Controls/src/Core/BindableObject.cs#L475-L511","documentation":"Thrown by SetDynamicResource(BindableProperty, string key, SetterSpecificity) when key is null or empty, via 'throw new ArgumentNullException(nameof(key))'. MAUI uses ArgumentNullException (rather than ArgumentException) for a missing resource key because a resource link is meaningless without it. The guard fires before OnSetDynamicResource, which would otherwise try to look up an empty key.","triggerScenarios":"Calling SetDynamicResource with a null or empty key; a resource key read from configuration/binding that was unset; building keys from null interpolation.","commonSituations":"Theme keys coming from a settings object whose property was not populated; conditional resource binding where the key defaulted to empty string.","solutions":["Provide a non-empty resource key that exists in a ResourceDictionary.","Guard before calling: 'if (!string.IsNullOrEmpty(key)) obj.SetDynamicResource(prop, key);'.","Fix the source of the key so it is always a real resource name."],"exampleFix":"// before\nobj.SetDynamicResource(prop, key);\n// after\nif (!string.IsNullOrEmpty(key))\n    obj.SetDynamicResource(prop, key);","handlingStrategy":"validation","validationCode":"if (string.IsNullOrEmpty(key)) throw new ArgumentException(\"resource key required\", nameof(key));\nobj.SetDynamicResource(property, key);","typeGuard":"static bool IsValidResourceKey(string key) => !string.IsNullOrWhiteSpace(key);","tryCatchPattern":null,"preventionTips":["Default theme-key properties to a real key, never empty string.","Validate keys against the ResourceDictionary before applying."],"tags":["maui","dynamic-resource","argument-null","resource-key"],"backgroundTag":null,"analyzedSha":"f377ff1c5ee04d334d8a925f50c83a6b7afddf03","analyzedAt":"2026-08-13T14:26:18.069Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}