dotnet/maui · error · BuildException

XC0100

XC0100

Error message

Syntax for x:Static is "[Member=][prefix:]typeName.staticMemberName".

What it means

Thrown by the XAML compiler (XamlC) when an x:Static markup extension's Member value is empty or lacks the required dot separator. x:Static requires the form '[prefix:]typeName.staticMemberName', so the compiler splits on the last '.' to find the type and the member; if no '.' exists it cannot split and aborts before any resolution is attempted.

Source

Thrown at src/Controls/src/Build.Tasks/CompiledMarkupExtensions/StaticExtension.cs:20

using System.Xml;
using Microsoft.Maui.Controls.Xaml;
using Mono.Cecil;
using Mono.Cecil.Cil;
using static System.String;

namespace Microsoft.Maui.Controls.Build.Tasks
{
	class StaticExtension : ICompiledMarkupExtension
	{
		public IEnumerable<Instruction> ProvideValue(ElementNode node, ModuleDefinition module, ILContext context, out TypeReference memberRef)
		{
			INode ntype;
			if (!node.Properties.TryGetValue(new XmlName("", "Member"), out ntype))
				ntype = node.CollectionItems[0];
			var member = ((ValueNode)ntype).Value as string;

			if (IsNullOrEmpty(member) || !member.Contains("."))
				throw new BuildException(BuildExceptionCode.XStaticSyntax, node as IXmlLineInfo, null);

			var dotIdx = member.LastIndexOf('.');
			var typename = member.Substring(0, dotIdx);
			var membername = member.Substring(dotIdx + 1);

			var typeRef = module.ImportReference(XmlTypeExtensions.GetTypeReference(context.Cache, typename, module, node as BaseNode, expandToExtension: false));
			var fieldRef = GetFieldReference(context.Cache, typeRef, membername, module);
			var propertyDef = GetPropertyDefinition(context.Cache, typeRef, membername, module);

			if (fieldRef == null && propertyDef == null)
				throw new BuildException(BuildExceptionCode.XStaticResolution, node as IXmlLineInfo, null, membername, typename);

			var fieldDef = fieldRef?.Resolve();
			if (fieldRef != null)
			{
				memberRef = fieldRef.FieldType;
				if (!fieldDef.HasConstant)
					return new[] { Instruction.Create(OpCodes.Ldsfld, fieldRef) };

View on GitHub (pinned to f377ff1c5e)

Solutions

  1. Rewrite the Member value to use the full form 'typeName.staticMemberName', e.g. Member="sys:Math.PI" with xmlns:sys declared.
  2. If omitting Member, place the full dotted expression as the element's first collection item.
  3. Verify the xmlns prefix mapping exists on the root element so the type portion resolves.
  4. Run a XAML lint/schema check that flags x:Static values missing a '.' character before building.

Example fix

// before
<Label Text="{x:Static PI}" />
// after
<Label Text="{x:Static sys:Math.PI}" />
  (root: xmlns:sys="clr-namespace:System;assembly=System.Runtime")
Defensive patterns

Strategy: validation

Validate before calling

// Pre-build XAML sanity check for x:Static
static bool IsValidXStaticMember(string member) =>
    !string.IsNullOrEmpty(member) && member.Contains('.');

// usage during authoring/CI lint:
// foreach attr ending in 'Member' or x:Static value -> IsValidXStaticMember(value)

Prevention

When it happens

Trigger: Writing <Label Text="{x:Static MyField}" /> (no dot), or <Label Text="{x:Static}" /> (empty Member), or omitting both the Member attribute and any collection item so 'member' resolves to null/empty. Also triggered by a Member like "{x:Static .}" whose only dot is the leading character, leaving an empty type segment.

Common situations: Forgetting the fully-qualified type prefix and writing only the member name; copy-pasting a C# identifier (e.g. Math.PI written as just PI); XAML authored before the namespace xmlns was declared so the type prefix is dropped; tools that strip namespaces when refactoring.

Related errors


AI-assisted analysis of dotnet/maui@f377ff1c5e (2026-08-13). Data as JSON: /api/errors/f37c015c3f5c8d98. Report an issue: GitHub.