dotnet/wpf · error · ArgumentException
The property 'propertyName' does not exist on type…
Error message
The property 'propertyName' does not exist on type 'sourceTypeName'.
What it means
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.
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).
Example fix
// before
propertyMap.Translate("Foreground", (o, e) => { ... }); // Foreground not on this control
// after
if (propertyMap.SourceObject.GetType().GetProperty("BackColor") != null)
{
propertyMap.Translate("BackColor", (o, e) => { ... });
} Defensive patterns
Strategy: validation
Validate before calling
if (propertyMap.SourceObject == null || propertyMap.SourceObject.GetType().GetProperty(propertyName) == null)
throw new InvalidOperationException($"Property '{propertyName}' does not exist on {propertyMap.SourceObject?.GetType().FullName}"); Type guard
bool IsMappedProperty(PropertyMap map, string name) =>
map.SourceObject?.GetType().GetProperty(name) != null; Try / catch
try { propertyMap.Translate(name, value); }
catch (ArgumentException ex) { log.Warn($"Skipping unmapped property '{name}'", ex); } Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- " }} " element found. Expected fixed page element ( }} ).
- ' '.' ' is a property without a getter and is not a valid…
- ' '.' ' is a property without a getter and is not a valid…
- ' '.' ' is a property without a getter and is not a valid…
- ' ' ContentType is not valid.
AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14).
Data as JSON: /api/errors/3f1c837fddd95978.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.DotNet.Wpf/src/WindowsFormsIntegration/System/Windows/Integration/PropertyMap.cs:140
/// <param name="propertyName">A string containing the name of the host control property to translate.</param>
/// <param name="translator">A PropertyTranslator delegate which will be called when the specificied property changes.</param>
public void Add(String propertyName, PropertyTranslator translator)
{
if (Contains(propertyName))
{
throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, SR.WFI_PropertyMappingExists, propertyName));
}
this[propertyName] = translator;
}
private void ThrowIfPropertyDoesntExistOnSource(string propertyName)
{
if (SourceObject != null)
{
if (GetProperty(propertyName) == null)
{
// Property 'Foreground' doesn't exist on type 'Window'
throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, SR.WFI_PropertyDoesntExist, propertyName, SourceObject.GetType().FullName));
}
}
}
/// <summary>
/// Runs the PropertyTranslator for the given property, based on the
/// SourceObject's current value.
/// </summary>
/// <param name="propertyName"></param>
public void Apply(string propertyName)
{
if (Contains(propertyName))
{
ThrowIfPropertyDoesntExistOnSource(propertyName);
PropertyInfo property = GetProperty(propertyName);
if (property != null)
{
RunTranslator(this[propertyName], SourceObject, propertyName, property.GetValue(SourceObject, null));View on GitHub (pinned to 81131a70a4)