unoplatform/uno · error · XamlObjectWriterException
Unresolved object reference '{0}' was found
Error message
Unresolved object reference '{0}' was found What it means
Thrown in ResolvePendingReferences (run at the end of writing) when an x:Reference name could not be resolved from either the name scope or the IXamlNameResolver. Forward/back references that remain unresolved at write completion surface here.
Source
Thrown at src/SourceGenerators/System.Xaml/System.Xaml/XamlObjectWriter.cs:604
}
internal IXamlNameResolver name_resolver {
get { return (IXamlNameResolver) service_provider.GetService (typeof (IXamlNameResolver)); }
}
internal override IAmbientProvider AmbientProvider {
get { return ambient_provider; }
}
void ResolvePendingReferences ()
{
foreach (var fixup in pending_name_references) {
foreach (var name in fixup.Names) {
bool isFullyInitialized;
// FIXME: sort out relationship between name_scope and name_resolver. (unify to name_resolver, probably)
var obj = name_scope.FindName (name) ?? name_resolver.Resolve (name, out isFullyInitialized);
if (obj == null)
throw new XamlObjectWriterException (String.Format (CultureInfo.InvariantCulture, "Unresolved object reference '{0}' was found", name));
if (!AddToCollectionIfAppropriate (fixup.ParentType, fixup.ParentMember, fixup.ParentValue, obj, null)) // FIXME: is keyObj always null?
SetValue (fixup.ParentMember, fixup.ParentValue, obj);
}
}
}
void HandleBeginInit (object value)
{
var si = value as ISupportInitialize;
if (si == null)
return;
si.BeginInit ();
source.OnAfterBeginInit (value);
}
void HandleEndInit (object value)
{
var si = value as ISupportInitialize;View on GitHub (pinned to 0418340488)
Solutions
- Ensure an element with `x:Name="<the name>"` exists in a scope visible to the resolver.
- Fix typos in the x:Reference Member value.
- If it is a forward reference, confirm the name resolver supports late resolution and that the name is truly in scope.
Example fix
<!-- before -->
<CheckBox IsChecked="{x:Reference Missing}" />
<!-- after -->
<CheckBox x:Name="cb" IsChecked="{x:Reference cb}" /> Defensive patterns
Strategy: validation
Validate before calling
// Before finishing, verify every x:Reference target has a matching x:Name in scope.
foreach (var name in referencedNames)
if (nameScope.FindName(name) == null)
throw new InvalidOperationException($"x:Reference target '{name}' is not defined."); Try / catch
try { /* write/load the full graph */ }
catch (XamlObjectWriterException ex) when (ex.Message.Contains("Unresolved object reference")) {
// a referenced name is missing or out of scope; add/fix x:Name.
} Prevention
- Add x:Name to any element targeted by x:Reference.
- Double-check spelling of referenced names.
- Confirm forward references are within a scope the name resolver can see.
When it happens
Trigger: XAML containing `<x:Reference Member="MissingName"/>` where no element has `x:Name="MissingName"` in any visible scope.
Common situations: Typo in the referenced name; forward reference to a name defined in a sibling/nested scope not visible to the resolver; missing x:Name on the target element.
Related errors
- serviceProvider does not implement IXamlNameResolver
- Member '{0}' is already written to current type '{1}'
- RootObjectInstance type '{0}' is not assignable to '{1}'
- The value for '{0}' property is null
- An error occurred on getting provided value
AI-assisted analysis of unoplatform/uno@0418340488 (2026-08-13).
Data as JSON: /api/errors/a20365b66c7d3b5d.
Report an issue: GitHub.