dotnet/wpf · error · ArgumentException
Unknown path operation attempted.
Error message
Unknown path operation attempted.
What it means
ParserStreamGeometryContext.PackByte throws ArgumentException with 'Unknown path operation attempted.' when a path geometry operation opcode is >= 16 and cannot fit into the packed byte format (the low 4 bits hold the opcode, the high bits hold boolean flags). This is an internal limit of the BAML/path-packing format, so it indicates a corrupted or invalid internal state rather than a caller mistake.
Solutions
- Verify the BAML/assembly was compiled with a compatible .NET/WPF version and rebuild resources
- Regenerate the corrupted resource or XAML compilation output (clean + rebuild)
- If hit in custom parsing code, ensure only defined ParserGeometryContextOpCodes values (< 16) are passed
Example fix
// before
context.PackByte((ParserGeometryContextOpCodes)unknownOp, ...);
// after
if (unknownOp >= ParserGeometryContextOpCodes.OpCodeLimit) throw new InvalidOperationException($"opcode {unknownOp} unsupported");
context.PackByte(knownOp, ...); Defensive patterns
Strategy: try-catch
Try / catch
try { ParsePath(data); } catch (ArgumentException ex) when (ex.Message.Contains("Unknown path operation")) { /* regenerate */ } Prevention
- Clean+rebuild resources after framework upgrades
- Avoid custom opcode packing code
When it happens
Trigger: Internal path-parsing/packing code invoking PackByte with an out-of-range ParserGeometryContextOpCodes value; feeding a corrupted BAML/stream geometry stream whose opcode byte decodes to an undefined operation.
Common situations: Deserializing BAML produced by an incompatible newer WPF version; corrupted XAML/BAML resources; memory corruption or a bug in custom derivation of the parsing pipeline.
Understand the failure class
Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.
Related errors
- Can't Assign to Known Type attributes
- Could not find prefix for type
- Found unexpected Xmlns BAML record
- NotImplementedException
- SR.AssemblyIdNegative
AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14).
Data as JSON: /api/errors/c61baaea52611222.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Media/ParserStreamGeometryContext.cs:715
// PackByte
// Packs an op-code, and up to 4 booleans into a single byte.
//
// Binary format is :
// First 4 bits map directly to the op-code.
// Next 4 bits map to booleans 1 - 4.
//
// Like this:
//
// 7| 6 | 5 | 4 | 3 | 2 | 1 | 0 |
// <B4>|<B3>|<B2>|<B1><- Op Code ->
//
private static byte PackByte(ParserGeometryContextOpCodes opCode, bool bool1, bool bool2, bool bool3, bool bool4)
{
byte packedByte = (byte) opCode;
if (packedByte >= 16)
{
throw new ArgumentException(SR.UnknownPathOperationType);
}
if (bool1)
{
packedByte |= SetBool1;
}
if (bool2)
{
packedByte |= SetBool2;
}
if (bool3)
{
packedByte |= SetBool3;
}
if (bool4)View on GitHub (pinned to 81131a70a4)