{"record":{"id":"2e164db5141f582f","repo":"BCUninstaller/Bulk-Crap-Uninstaller","slug":"resource-of-this-type-doesn-t-contain-specified-pr","errorCode":null,"errorMessage":"Resource of this type doesn't contain specified property","messagePattern":"Resource of this type doesn't contain specified property","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"source/KlocTools/Localising/LocalisedNameAttribute.cs","lineNumber":42,"sourceCode":"            ResourceType = resourceType;\n        }\n\n        private string NameOverride { get; }\n        private string ResourceName { get; }\n        private Type ResourceType { get; }\n\n        public string GetName()\n        {\n            if (NameOverride != null)\n                return NameOverride;\n\n            if ((ResourceType != null) && (ResourceName != null))\n            {\n                var property = ResourceType.GetProperty(ResourceName,\n                    BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);\n                if (property == null)\n                {\n                    throw new InvalidOperationException(\"Resource of this type doesn\\'t contain specified property\");\n                }\n                if (property.PropertyType != typeof (string))\n                {\n                    throw new InvalidOperationException(\"Specified property is not of string type\");\n                }\n                return (string) property.GetValue(null, null);\n            }\n            return string.Empty;\n        }\n    }\n}","sourceCodeStart":24,"sourceCodeEnd":53,"githubUrl":"https://github.com/BCUninstaller/Bulk-Crap-Uninstaller/blob/608321de98e92297377b1eb69029af55c25504a1/source/KlocTools/Localising/LocalisedNameAttribute.cs#L24-L53","documentation":"Thrown by LocalisedNameAttribute.GetName() when both ResourceType and ResourceName are set but ResourceType.GetProperty(ResourceName, Public|NonPublic|Static) returns null. That means the named resource entry does not exist on the referenced resource (RESX-generated) class, so the attribute cannot resolve a display string and raises InvalidOperationException.","triggerScenarios":"Decorating a member with [LocalisedName(ResourceType = typeof(MyResources), ResourceName = \"MissingKey\")] where \"MissingKey\" is not a static string property on MyResources (typo, key deleted, wrong resource class, or resource not compiled).","commonSituations":"Renaming or deleting a RESX entry without updating attributes, pointing ResourceType at the wrong resource class, namespace/resx generation disabled, or splitting resources across assemblies without setting InternalVisibleTo.","solutions":["Open the referenced .resx and add the missing key named exactly as ResourceName (case-sensitive).","Correct the ResourceName spelling / casing to match an existing static string property on ResourceType.","Point ResourceType at the resource class that actually owns the key, and rebuild so the RESX designer regenerates the property."],"exampleFix":"// before\n[LocalisedName(ResourceType = typeof(Strings), ResourceName = \"UsrName\")]\npublic string UserName { get; set; } // Strings has no \"UsrName\"\n\n// after (match the RESX key exactly)\n[LocalisedName(ResourceType = typeof(Strings), ResourceName = \"UserName\")]","handlingStrategy":"validation","validationCode":"// Verify the resource key exists at startup\nvar prop = typeof(Strings).GetProperty(keyName,\n    BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);\nif (prop == null) logger.Error($\"Missing resource key {keyName}\");","typeGuard":"static bool ResourceKeyExists(Type resType, string key)\n    => resType.GetProperty(key, BindingFlags.Public | BindingFlags.Static) != null;","tryCatchPattern":"try { attr.GetName(); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"doesn't contain\"))\n{ /* fall back to member.Name, and log the missing key */ }","preventionTips":["Run a startup self-check that every LocalisedName ResourceName resolves on its ResourceType.","Gate RESX renames/deletes behind a find-usages sweep over attributes.","Keep resource key spelling consistent with a unit test that enumerates decorated members."],"tags":["resources","localisation","reflection","csharp","kloctools"],"backgroundTag":null,"analyzedSha":"608321de98e92297377b1eb69029af55c25504a1","analyzedAt":"2026-08-13T12:17:35.389Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}