unoplatform/uno · error · XamlObjectWriterException
Referenced value method {0} in type {1} indicated by event {
Error message
Referenced value method {0} in type {1} indicated by event {2} was not found What it means
Thrown in SetEvent after resolving the owner type and splitting the handler method name: the writer looks for an instance method (public or non-public) on the root-state value's runtime type whose parameter types match the event handler delegate's Invoke signature. If no such method exists, it throws.
Source
Thrown at src/SourceGenerators/System.Xaml/System.Xaml/XamlObjectWriter.cs:391
if (member.UnderlyingMember == null)
throw new XamlObjectWriterException (String.Format (CultureInfo.InvariantCulture, "Event {0} has no underlying member to attach event", member));
int idx = value.LastIndexOf ('.');
var xt = idx < 0 ? root_state.Type : ResolveTypeFromName (value.Substring (0, idx));
if (xt == null)
throw new XamlObjectWriterException (String.Format (CultureInfo.InvariantCulture, "Referenced type {0} in event {1} was not found", value, member));
if (xt.UnderlyingType == null)
throw new XamlObjectWriterException (String.Format (CultureInfo.InvariantCulture, "Referenced type {0} in event {1} has no underlying type", value, member));
string mn = idx < 0 ? value : value.Substring (idx + 1);
var ev = (EventInfo) member.UnderlyingMember;
// get an appropriate MethodInfo overload whose signature matches the event's handler type.
// FIXME: this may need more strict match. RuntimeBinder may be useful here.
var eventMethodParams = ev.EventHandlerType.GetMethod ("Invoke").GetParameters ();
var target = root_state.Value;
var mi = target.GetType().GetMethod (mn, BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public, null, (from pi in eventMethodParams select pi.ParameterType).ToArray (), null);
if (mi == null)
throw new XamlObjectWriterException (String.Format (CultureInfo.InvariantCulture, "Referenced value method {0} in type {1} indicated by event {2} was not found", mn, value, member));
var obj = object_states.Peek ().Value;
ev.AddEventHandler (obj, Delegate.CreateDelegate (ev.EventHandlerType, target, mi));
}
void SetValue (XamlMember member, object value)
{
if (member == XamlLanguage.FactoryMethod)
object_states.Peek ().FactoryMethod = (string) value;
else if (member.IsDirective)
return;
else
SetValue (member, object_states.Peek ().Value, value);
}
void SetValue (XamlMember member, object target, object value)
{
if (!source.OnSetValue (target, member, value))
member.Invoker.SetValue (target, value);View on GitHub (pinned to 0418340488)
Solutions
- Add an instance method with the signature matching the event's delegate: `void Handler(object sender, TEventArgs e)`.
- Ensure the method is an instance method (the binding flags request Instance), not static.
- Confirm the handler lives on the type that is the writer's root-state value (the target).
Example fix
// before
private static void OnClick() { }
// after
private void OnClick(object sender, RoutedEventArgs e) { } Defensive patterns
Strategy: validation
Validate before calling
// Confirm an instance method with the delegate's signature exists on the target.
var invokeParams = ev.EventHandlerType.GetMethod("Invoke").GetParameters()
.Select(p => p.ParameterType).ToArray();
var handler = target.GetType().GetMethod(handlerName,
BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic,
null, invokeParams, null);
if (handler == null)
throw new InvalidOperationException($"No matching handler '{handlerName}'."); Try / catch
try { /* write event */ }
catch (XamlObjectWriterException ex) when (ex.Message.Contains("value method") && ex.Message.Contains("was not found")) {
// add/rename the handler method with the delegate's exact signature.
} Prevention
- Match the handler signature to the event delegate exactly (object sender, TEventArgs e).
- Keep handlers as instance methods on the root-state value type.
- Rename handler call sites when renaming methods.
When it happens
Trigger: Event handler value 'ClickHandler' where ClickHandler does not exist on the root type, or exists but with the wrong signature (e.g. `void ClickHandler()` instead of `void ClickHandler(object, RoutedEventArgs)`), or is static rather than instance.
Common situations: Handler method renamed; signature changed; method is static; method lives on a different type than the root state value; typo in handler name.
Related errors
- Event {0} has no underlying member to attach event
- Specified static factory method '{0}' for type '{1}' was not
- Referenced type {0} in event {1} was not found
- Referenced type {0} in event {1} has no underlying type
- The {0} string passed in the colorString argument is not a r
AI-assisted analysis of unoplatform/uno@0418340488 (2026-08-13).
Data as JSON: /api/errors/10713caa91335f99.
Report an issue: GitHub.