dotnet/wpf · error · InvalidOperationException
Invalid ISF tag logic
Error message
Invalid ISF tag logic
What it means
The tag switch in DecodeRawISF has a default case that throws InvalidOperationException, meaning the decoder encountered an ISF tag value it has no handler for. Unlike the ArgumentException guards (which detect size/consistency problems), this indicates the tag itself is outside the set the decoder understands — malformed or unsupported ISF data, or an internal logic gap.
Solutions
- Regenerate the ISF with a writer compatible with the consuming WPF version.
- Update to a newer .NET/WPF runtime whose decoder handles the tag in question.
- Locate the offending tag bytes (compare with a known-good payload) to identify corruption.
- Catch InvalidOperationException around DecodeISF and treat the stream as unsupported rather than crashing the app.
Example fix
// before
var strokes = StrokeCollectionSerializer.DecodeISF(stream); // unhandled tag crashes
// after
try { var strokes = StrokeCollectionSerializer.DecodeISF(stream); }
catch (InvalidOperationException ex) { Log.Warn("Unsupported ISF tag", ex); strokes = new StrokeCollection(); } Defensive patterns
Strategy: try-catch
Try / catch
try { return DecodeISF(stream); } catch (InvalidOperationException ex) { logger.Warn(ex, "Unsupported/unknown ISF tag"); return new StrokeCollection(); } Prevention
- Pin or align the WPF/.NET version between writer and reader of ISF data.
- Treat ISF as versioned data; record the producing app/version alongside the blob.
- Catch both ArgumentException and InvalidOperationException at decode boundaries.
- Sanity-check unknown tag values when debugging corrupt streams.
When it happens
Trigger: Decoding an ISF stream containing a tag not covered by any case in the DecodeRawISF switch (e.g. a newer/proprietary ISF tag, corrupt bytes flipping a tag value, or an unhandled valid tag).
Common situations: ISF produced by newer or non-Microsoft ink implementations using tags this WPF version doesn't know; bit-corrupted tag values; loading ISF on an older .NET/WPF version than the writer.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- Buffer range is smaller than expected expected size
- Button data length not equal to expected length
- Drawing Attribute tag embedded in ISF stream does not match…
- Empty data to load
- ExtendedProperty decoded totalBytesInStrokeBlockOfIsfStream…
AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14).
Data as JSON: /api/errors/4fd9a2e76fcf83a2.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Ink/InkSerializedFormat/InkSerializer.cs:660
// Load the stroke
Stroke localStroke;
#if OLD_ISF
localBytesDecoded = StrokeSerializer.DecodeStroke(inputStream, bytesDecodedInCurrentTag, guidList, strokeDescriptor, currentStylusPointDescription, activeDrawingAttributes, currentTabletToInkTransform, compressor, out localStroke);
#else
localBytesDecoded = StrokeSerializer.DecodeStroke(inputStream, bytesDecodedInCurrentTag, guidList, strokeDescriptor, currentStylusPointDescription, activeDrawingAttributes, currentTabletToInkTransform, out localStroke);
#endif
if (localStroke != null)
{
_coreStrokes.AddWithoutEvent(localStroke);
strokeIndex++;
}
break;
}
default:
{
throw new InvalidOperationException(ISFDebugMessage("Invalid ISF tag logic"));
}
}
// if this isfTag's decoded size != expected size, then error out
if (localBytesDecoded != bytesDecodedInCurrentTag)
{
throw new ArgumentException(ISFDebugMessage("Invalid ISF data"));
}
break;
}
case KnownTagCache.KnownTagIndex.Transform:
case KnownTagCache.KnownTagIndex.TransformIsotropicScale:
case KnownTagCache.KnownTagIndex.TransformAnisotropicScale:
case KnownTagCache.KnownTagIndex.TransformRotate:
case KnownTagCache.KnownTagIndex.TransformTranslate:
case KnownTagCache.KnownTagIndex.TransformScaleAndTranslate:View on GitHub (pinned to 81131a70a4)