{"record":{"id":"10713caa91335f99","repo":"unoplatform/uno","slug":"referenced-value-method-0-in-type-1-indicated","errorCode":null,"errorMessage":"Referenced value method {0} in type {1} indicated by event {2} was not found","messagePattern":"Referenced value method (.+?) in type (.+?) indicated by event (.+?) was not found","errorType":"exception","errorClass":"XamlObjectWriterException","httpStatus":null,"severity":"error","filePath":"src/SourceGenerators/System.Xaml/System.Xaml/XamlObjectWriter.cs","lineNumber":391,"sourceCode":"\t\t\tif (member.UnderlyingMember == null)\n\t\t\t\tthrow new XamlObjectWriterException (String.Format (CultureInfo.InvariantCulture, \"Event {0} has no underlying member to attach event\", member));\n\n\t\t\tint idx = value.LastIndexOf ('.');\n\t\t\tvar xt = idx < 0 ? root_state.Type : ResolveTypeFromName (value.Substring (0, idx));\n\t\t\tif (xt == null)\n\t\t\t\tthrow new XamlObjectWriterException (String.Format (CultureInfo.InvariantCulture, \"Referenced type {0} in event {1} was not found\", value, member));\n\t\t\tif (xt.UnderlyingType == null)\n\t\t\t\tthrow new XamlObjectWriterException (String.Format (CultureInfo.InvariantCulture, \"Referenced type {0} in event {1} has no underlying type\", value, member));\n\t\t\tstring mn = idx < 0 ? value : value.Substring (idx + 1);\n\t\t\tvar ev = (EventInfo) member.UnderlyingMember;\n\t\t\t// get an appropriate MethodInfo overload whose signature matches the event's handler type.\n\t\t\t// FIXME: this may need more strict match. RuntimeBinder may be useful here.\n\t\t\tvar eventMethodParams = ev.EventHandlerType.GetMethod (\"Invoke\").GetParameters ();\n\t\t\t\n\t\t\tvar target = root_state.Value;\n\t\t\tvar mi = target.GetType().GetMethod (mn, BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public, null, (from pi in eventMethodParams select pi.ParameterType).ToArray (), null);\n\t\t\tif (mi == null)\n\t\t\t\tthrow new XamlObjectWriterException (String.Format (CultureInfo.InvariantCulture, \"Referenced value method {0} in type {1} indicated by event {2} was not found\", mn, value, member));\n\t\t\tvar obj = object_states.Peek ().Value;\n\t\t\tev.AddEventHandler (obj, Delegate.CreateDelegate (ev.EventHandlerType, target, mi));\n\t\t}\n\n\t\tvoid SetValue (XamlMember member, object value)\n\t\t{\n\t\t\tif (member == XamlLanguage.FactoryMethod)\n\t\t\t\tobject_states.Peek ().FactoryMethod = (string) value;\n\t\t\telse if (member.IsDirective)\n\t\t\t\treturn;\n\t\t\telse\n\t\t\t\tSetValue (member, object_states.Peek ().Value, value);\n\t\t}\n\t\t\n\t\tvoid SetValue (XamlMember member, object target, object value)\n\t\t{\n\t\t\tif (!source.OnSetValue (target, member, value))\n\t\t\t\tmember.Invoker.SetValue (target, value);","sourceCodeStart":373,"sourceCodeEnd":409,"githubUrl":"https://github.com/unoplatform/uno/blob/04183404888ea21b4e5bfa3493e8d5f15e972c3a/src/SourceGenerators/System.Xaml/System.Xaml/XamlObjectWriter.cs#L373-L409","documentation":"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.","triggerScenarios":"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.","commonSituations":"Handler method renamed; signature changed; method is static; method lives on a different type than the root state value; typo in handler name.","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)."],"exampleFix":"// before\nprivate static void OnClick() { }\n// after\nprivate void OnClick(object sender, RoutedEventArgs e) { }","handlingStrategy":"validation","validationCode":"// Confirm an instance method with the delegate's signature exists on the target.\nvar invokeParams = ev.EventHandlerType.GetMethod(\"Invoke\").GetParameters()\n    .Select(p => p.ParameterType).ToArray();\nvar handler = target.GetType().GetMethod(handlerName,\n    BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic,\n    null, invokeParams, null);\nif (handler == null)\n    throw new InvalidOperationException($\"No matching handler '{handlerName}'.\");","typeGuard":null,"tryCatchPattern":"try { /* write event */ }\ncatch (XamlObjectWriterException ex) when (ex.Message.Contains(\"value method\") && ex.Message.Contains(\"was not found\")) {\n    // add/rename the handler method with the delegate's exact signature.\n}","preventionTips":["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."],"tags":["xaml","event","reflection","object-writer"],"backgroundTag":null,"analyzedSha":"04183404888ea21b4e5bfa3493e8d5f15e972c3a","analyzedAt":"2026-08-13T21:08:11.651Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}