dotnet/wpf · error · XamlSchemaException
' '.' ' is a property without a getter and is not a valid…
Error message
'{0}'.'{1}' is a property without a getter and is not a valid XAML property. What it means
ClrProperty wraps a CLR PropertyInfo for XAML schema use. It demands a getter: if pi.GetGetMethod(true) returns null the property is write-only, which is not a valid XAML property, so a XamlSchemaException (SR.SetOnlyProperty) is thrown naming declaringType and the property.
Solutions
- Add a getter to the property (it can be less accessible, e.g. private, but must exist).
- Replace the set-only property with a public field or a full property.
- Point the XAML schema at a different member that is readable.
Example fix
// before
public string Secret { set { _secret = value; } }
// after
public string Secret { get; set; }
// or keep setter private getter:
public string Secret { private get; set; } Defensive patterns
Strategy: type-guard
Validate before calling
// before using a property in XAML
if (propInfo.GetGetMethod(true) == null)
throw new InvalidOperationException($"{propInfo.DeclaringType}.{propInfo.Name} is write-only; add a getter"); Type guard
bool IsReadable(PropertyInfo p) => p.GetGetMethod(true) != null; bool IsXamlUsable(PropertyInfo p) => p.CanRead || p.CanWrite && p.GetGetMethod(true) != null;
Try / catch
try { member = new ClrProperty(name, propInfo, declaringType, schemaContext); }
catch (XamlSchemaException ex) { log($"Write-only property: {ex.Message}"); } Prevention
- Never declare set-only properties on XAML-exposed types.
- If the getter must be hidden, make it private/internal rather than omitting it.
- Scan assemblies for CanRead == false properties before XAML use.
When it happens
Trigger: Constructing ClrProperty from a PropertyInfo that has no get accessor at all (public or private), e.g. a property with only a set accessor.
Common situations: Write-only properties in view-models or custom markup-extension targets referenced from XAML; code-generation emitting set-only properties; languages/platforms where GetGetMethod(true) still returns null because no getter was declared.
Understand the failure class
Background: "not installed", "pip install", "required for": how missing-dependency errors surface across open-source libraries — this error's family across 34 libraries.
Related errors
- ' '.' ' is a property without a getter and is not a valid…
- ' '.' ' is a property without a getter and is not a valid…
- Attached property setter and attached event adder methods…
- Can't Assign to Known Member attributes
- SR.Format(SR.MarkupExtensionBadStatic, typeNameForError is…
AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14).
Data as JSON: /api/errors/e8fd7e62a5afd99f.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/Schema/ClrProperty.cs:80
public ClrProperty(string name, PropertyInfo pi, XamlType declaringType)
: this(name, pi, declaringType, false)
{
}
private ClrProperty(string name, PropertyInfo pi, XamlType declaringType, bool isStatic)
{
Debug.Assert(pi != null);
Debug.Assert(pi.Name == name);
#if DEBUG
if (declaringType == null)
{
throw new XamlInternalException("Asserting that the declaringType should never be null");
}
#endif
MethodInfo mi = pi.GetGetMethod(true);
if (mi == null)
{
throw new XamlSchemaException(SR.Format(SR.SetOnlyProperty, declaringType.Name, name));
}
_declaringType = declaringType;
_name = pi.Name;
_isPublic = mi.IsPublic;
_isReadOnly = !pi.CanWrite;
_isStatic = isStatic;
ClrBindingPropertyInfo = pi;
_isAttachable = false;
_isEvent = false;
OtherInitialization();
}
private void OtherInitialization()View on GitHub (pinned to 81131a70a4)