unoplatform/uno · error · NotSupportedException
Attempt to set value from read-only property {0}
Error message
Attempt to set value from read-only property {0} What it means
Thrown by XamlMemberInvoker.SetValue when the member has no UnderlyingSetter. This happens for read-only properties (no setter) and for events that cannot be set via reflection. The invoker refuses to write a value it has no method to write with.
Source
Thrown at src/SourceGenerators/System.Xaml/System.Xaml.Schema/XamlMemberInvoker.cs:83
{
ThrowIfUnknown ();
if (instance == null)
throw new ArgumentNullException ("instance");
if (member is XamlDirective)
throw new NotSupportedException (String.Format (CultureInfo.InvariantCulture, "not supported operation on directive member {0}", member));
if (UnderlyingGetter == null)
throw new NotSupportedException (String.Format (CultureInfo.InvariantCulture, "Attempt to get value from write-only property or event {0}", member));
return UnderlyingGetter.Invoke (instance, Array.Empty<object>());
}
public virtual void SetValue (object instance, object value)
{
ThrowIfUnknown ();
if (instance == null)
throw new ArgumentNullException ("instance");
if (member is XamlDirective)
throw new NotSupportedException (String.Format (CultureInfo.InvariantCulture, "not supported operation on directive member {0}", member));
if (UnderlyingSetter == null)
throw new NotSupportedException (String.Format (CultureInfo.InvariantCulture, "Attempt to set value from read-only property {0}", member));
if (member.IsAttachable)
UnderlyingSetter.Invoke (null, new object [] {instance, value});
else
UnderlyingSetter.Invoke (instance, new object [] {value});
}
public virtual ShouldSerializeResult ShouldSerializeValue (object instance)
{
throw new NotImplementedException ();
}
}
}
View on GitHub (pinned to 0418340488)
Solutions
- Do not attempt to set read-only members from XAML; mark them with DesignerSerializationVisibility.Hidden or [Bindable(false)] if appropriate.
- Check `member.Invoker.UnderlyingSetter != null` (or member.IsWriteVisible) before calling SetValue.
- Add a public setter to the property if it should be XAML-settable.
- If trimming removed the setter, ensure the type/property is preserved via DynamicDependency or trimming annotations.
Example fix
// before
member.Invoker.SetValue(instance, value);
// after
if (member.Invoker.UnderlyingSetter == null) {
// read-only or event member; skip or log
return;
}
member.Invoker.SetValue(instance, value); Defensive patterns
Strategy: validation
Validate before calling
// before SetValue
if (member.Invoker.UnderlyingSetter == null) {
// read-only or event member: skip, log, or report
return;
} Prevention
- Check member.IsWriteVisible / UnderlyingSetter before writing.
- Do not assign read-only CLR properties from XAML; review DesignerSerializationVisibility.
When it happens
Trigger: Calling SetValue on a XamlMember backed by a get-only property, a computed property, or an event member. Also when a property's setter is non-public and the XamlMember was built without reflecting the setter.
Common situations: XAML that tries to assign a read-only CLR property; binding to a property with only a getter; version changes where a previously settable property became read-only; reflecting internal/private setters under trimming where the setter was removed.
Related errors
- Current operation is valid only when the underlying type on
- The collection type '{0}' does not have 'Add' method
- type
- instance
- item
AI-assisted analysis of unoplatform/uno@0418340488 (2026-08-13).
Data as JSON: /api/errors/4a8d95420cfe08d7.
Report an issue: GitHub.