unoplatform/uno · error · InvalidOperationException

Name property is not set

Error message

Name property is not set

What it means

InvalidOperationException thrown by Bind.ProvideValue (System.Xaml, ported from Mono) when the Path property is null. Path is the named reference Bind resolves via IXamlNameResolver; without it there is nothing to bind. Note the message says 'Name property is not set' even though the property is called Path — a long-standing wording quirk in this port.

Source

Thrown at src/SourceGenerators/System.Xaml/System.Windows.Markup/Bind.cs:35

		public Bind(string path)
		{
			Path = path;
		}

		[ConstructorArgument ("path")]
		public string Path { get; set; }

		public override object ProvideValue (IServiceProvider serviceProvider)
		{
			if (serviceProvider == null)
			{
				throw new ArgumentNullException ("serviceProvider");
			}

			if (Path == null)
			{
				throw new InvalidOperationException ("Name property is not set");
			}

			var r = serviceProvider.GetService (typeof (IXamlNameResolver)) as IXamlNameResolver;
			if (r == null)
			{
				throw new InvalidOperationException ("serviceProvider does not implement IXamlNameResolver");
			}

			var ret = r.Resolve (Path);
			if (ret == null)
			{
				ret = r.GetFixupToken (new string [] { Path }, true);
			}

			return ret;
		}
	}
}

View on GitHub (pinned to 0418340488)

Solutions

  1. Always supply Path via the Bind(string path) constructor or set the Path property before ProvideValue.
  2. In XAML, ensure the Bind markup extension includes its path argument.
  3. Add a guard: if (bind.Path is null) bind.Path = expectedPath; before evaluation.

Example fix

// before
var b = new Bind();
b.ProvideValue(sp); // Path is null

// after
var b = new Bind("MyTargetName");
b.ProvideValue(sp);
Defensive patterns

Strategy: validation

Validate before calling

static Bind RequirePath(Bind b) => b.Path is null ? throw new InvalidOperationException("Bind.Path is required.") : b;

Type guard

static bool IsReady(Bind b) => !string.IsNullOrEmpty(b.Path);

Try / catch

try { return b.ProvideValue(sp); } catch (InvalidOperationException ex) when (ex.Message.Contains("Name property is not set")) { b.Path = fallbackPath; return b.ProvideValue(sp); }

Prevention

When it happens

Trigger: Constructing Bind without a path (parameterless) and calling ProvideValue, or a XAML usage that omits the path argument.

Common situations: Default-constructing Bind in code and forgetting to set Path, or malformed markup that does not supply the constructor argument.

Related errors


AI-assisted analysis of unoplatform/uno@0418340488 (2026-08-13). Data as JSON: /api/errors/770a57555746d720. Report an issue: GitHub.