{"record":{"id":"3f1c837fddd95978","repo":"dotnet/wpf","slug":"the-property-propertyname-does-not-exist-on-type","errorCode":null,"errorMessage":"The property 'propertyName' does not exist on type 'sourceTypeName'.","messagePattern":"The property 'propertyName' does not exist on type 'sourceTypeName'\\.","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/WindowsFormsIntegration/System/Windows/Integration/PropertyMap.cs","lineNumber":140,"sourceCode":"        /// <param name=\"propertyName\">A string containing the name of the host control property to translate.</param>\n        /// <param name=\"translator\">A PropertyTranslator delegate which will be called when the specificied property changes.</param>\n        public void Add(String propertyName, PropertyTranslator translator)\n        {\n            if (Contains(propertyName))\n            {\n                throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, SR.WFI_PropertyMappingExists, propertyName));\n            }\n            this[propertyName] = translator;\n        }\n\n        private void ThrowIfPropertyDoesntExistOnSource(string propertyName)\n        {\n            if (SourceObject != null)\n            {\n                if (GetProperty(propertyName) == null)\n                {\n                    // Property 'Foreground' doesn't exist on type 'Window'\n                    throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, SR.WFI_PropertyDoesntExist, propertyName, SourceObject.GetType().FullName));\n                }\n            }\n        }\n\n        /// <summary>\n        ///     Runs the PropertyTranslator for the given property, based on the \n        ///     SourceObject's current value.\n        /// </summary>\n        /// <param name=\"propertyName\"></param>\n        public void Apply(string propertyName)\n        {\n            if (Contains(propertyName))\n            {\n                ThrowIfPropertyDoesntExistOnSource(propertyName);\n                PropertyInfo property = GetProperty(propertyName);\n                if (property != null)\n                {\n                    RunTranslator(this[propertyName], SourceObject, propertyName, property.GetValue(SourceObject, null));","sourceCodeStart":122,"sourceCodeEnd":158,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/WindowsFormsIntegration/System/Windows/Integration/PropertyMap.cs#L122-L158","documentation":"PropertyMap throws this ArgumentException when a caller attempts to Translate, Apply, Add, or Reset a property name that does not exist on the wrapped Windows Forms SourceObject. PropertyMap only maps properties that the underlying WinForms control actually exposes; GetProperty(propertyName) returns null when the reflection lookup fails, so the map refuses to proceed rather than silently ignoring the request.","triggerScenarios":"Calling propertyMap.Translate(\"Foreground\", value) or propertyMap.Apply() when 'Foreground' is not a property of SourceObject (e.g. mapping a WPF-style property name onto a control that lacks it); passing a misspelled property name; using PropertyMap on a System.Windows.Forms.Integration.WindowsFormsHost with a Child control whose property set differs from what was assumed.","commonSituations":"Copy-pasting PropertyMap setup code between controls of different types; renaming properties on a custom WinForms control that a PropertyMap still references; assuming WPF property casing/names on a WinForms control; .NET version changes removing or renaming a control property.","solutions":["Verify the property exists on the SourceObject's concrete type and fix the spelling/casing of the property name.","Check with propertyMap.SourceObject.GetType().GetProperty(\"<name>\") before mapping.","Remove obsolete entries from the PropertyMap for properties that no longer exist on the control.","Ensure SourceObject is the type you expect (check SourceObject.GetType().FullName in the message)."],"exampleFix":"// before\npropertyMap.Translate(\"Foreground\", (o, e) => { ... }); // Foreground not on this control\n// after\nif (propertyMap.SourceObject.GetType().GetProperty(\"BackColor\") != null)\n{\n    propertyMap.Translate(\"BackColor\", (o, e) => { ... });\n}","handlingStrategy":"validation","validationCode":"if (propertyMap.SourceObject == null || propertyMap.SourceObject.GetType().GetProperty(propertyName) == null)\n    throw new InvalidOperationException($\"Property '{propertyName}' does not exist on {propertyMap.SourceObject?.GetType().FullName}\");","typeGuard":"bool IsMappedProperty(PropertyMap map, string name) =>\n    map.SourceObject?.GetType().GetProperty(name) != null;","tryCatchPattern":"try { propertyMap.Translate(name, value); }\ncatch (ArgumentException ex) { log.Warn($\"Skipping unmapped property '{name}'\", ex); }","preventionTips":["Confirm property names against the concrete WinForms control type before mapping","Use nameof() instead of string literals for property names","Check PropertyMap keys/DefaultTranslators to see which properties are actually mapped"],"tags":["reflection","property-map","argument","windowsforms-integration"],"backgroundTag":"invalid-argument-value","analyzedSha":"81131a70a4c573cd62748a5c36908fc4d662daa9","analyzedAt":"2026-09-14T10:12:48.479Z","contentChangedAt":"2026-09-14T10:12:48.479Z","schemaVersion":2},"datasetVersion":"2026-09-21T21:30:21.729Z"}