dotnet/wpf · error · XamlParseException
SR.MissingComma1 / SR.MissingComma2 (built into 'error')
Error message
SR.MissingComma1 / SR.MissingComma2 (built into 'error')
What it means
In P_NamedArg, a positional or named argument sequence must be comma-separated. When the scanner's current token isn't the expected ',' the parser builds an error via SR.MissingComma1 (after a positional arg) or SR.MissingComma2 (with the current member name and offending token text) and throws XamlParseException.
Solutions
- Insert the missing comma between arguments
- Use '=' and ',' correctly for named arguments: Path=Text, ElementName=Btn
- Check the member/token named in the error message to find the exact split point
Example fix
// before
<TextBlock Text="{Binding Path=Name ElementName=Btn}"/>
// after
<TextBlock Text="{Binding Path=Name, ElementName=Btn}"/> Defensive patterns
Strategy: validation
Validate before calling
bool ArgumentsCommaSeparated(string s)
{
// crude pre-check: tokens between '=' assignments must start with ','
int i = 0;
while ((i = s.IndexOf('=', i + 1)) > 0)
{
int next = s.IndexOf("=", i + 1);
int comma = s.IndexOf(',', i);
if (next > 0 && (comma < 0 || comma > next)) return false;
}
return true;
} Try / catch
try { nodes = parser.Parse(meString); }
catch (XamlParseException ex) when (ex.Message.Contains("comma") || ex.Message.Contains("','")) { /* point user to the member named in the message */ } Prevention
- Separate named arguments with ', Name=Value'
- Validate argument syntax in editors/snippets
- Copy from working examples rather than retyping
When it happens
Trigger: Markup-extension argument lists missing a comma between arguments, e.g. '{StaticResource Foo Bar}' or '{Binding Path=Text ElementName=Btn}' where 'ElementName' needs a preceding comma.
Common situations: Hand-written markup extensions forgetting comma separators, copying positional-style arguments into named-argument form, typos deleting the comma.
Understand the failure class
Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.
Related errors
- ArgumentNullException(nameof(arrayType))
- ArgumentNullException(nameof(member))
- brokenRule (SR.UnexpectedToken-based parser rule error)
- IAmbientProvider
- IXamlSchemaContextProvider
AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14).
Data as JSON: /api/errors/4e89862107cad0af.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.DotNet.Wpf/src/System.Xaml/System/Xaml/Parser/MePullParser.cs:471
yield return node;
}
f.found = f2.found;
break;
case MeTokenType.PropertyName:
{
string error;
if (_context.CurrentMember is null)
{
error = SR.Format(SR.MissingComma1, _tokenizer.TokenText);
}
else
{
error = SR.Format(SR.MissingComma2, _context.CurrentMember.Name, _tokenizer.TokenText);
}
throw new XamlParseException(_tokenizer, error);
}
default:
SetBrokenRuleString("NamedArg ::= PROPERTYNAME '=' @(STRING | QUOTEDMARKUPEXTENSION | MarkupExtension)");
break;
}
yield return Logic_EndMember();
}
}
// ================================================
private void NextToken()
{
_tokenizer.Read();
}
View on GitHub (pinned to 81131a70a4)