dotnet/wpf · error · InvalidOperationException

ROP data size was not found

Error message

ROP data size was not found

What it means

For the RasterOperation guid, DecodeAsISF expects a known fixed data size via GuidList.GetDataSizeIfKnownGuid(KnownIds.RasterOperation). If that returns 0, the internal guid-size table is missing the entry, and an InvalidOperationException is thrown — an internal invariant violation rather than bad user data.

Solutions

  1. Use the standard GuidList with all known ids registered
  2. Restore the size table entry for KnownIds.RasterOperation
  3. Verify you are calling the serializer's public surface rather than reimplementing table lookups
  4. Report as a bug if it occurs with the stock library and valid ISF

Example fix

// before
customList.Remove(KnownIds.RasterOperation); // size lookup now returns 0
// after
// keep known ids intact
guidList = GuidList.CopyWithCustomEntries(userGuids); // standard table + custom additions
Defensive patterns

Strategy: try-catch

Validate before calling

if (GuidList.GetDataSizeIfKnownGuid(KnownIds.RasterOperation) == 0) throw new InvalidOperationException("guid size table incomplete");

Try / catch

try { DecodeAsISF(stream, guidList, maxSize); }
catch (InvalidOperationException ex) when (ex.Message.Contains("ROP")) { /* bug report / fix table */ }

Prevention

When it happens

Trigger: Decoding ISF containing a RasterOperation drawing attribute while the guid/size table lookup returns 0 — practically only when the guid table is incomplete, custom-built, or the code path is fed an unexpected table.

Common situations: Custom or partial GuidList implementations; modified guid tables missing known-id sizes; regression from refactoring serializer tables.

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


AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14). Data as JSON: /api/errors/5a2b87615a35cda6. Report an issue: GitHub.

Appendix: source

Thrown at src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Ink/InkSerializedFormat/DrawingAttributeSerializer.cs:177

                {
                    cb = SerializationHelper.Decode(stream, out dw);
                    penStyle = (PenStyle)dw;
                    maximumStreamSize -= cb;
                }
                else if (KnownIds.DrawingFlags == guid)
                {
                    // Encode the drawing flags with considerations for v2 model
                    cb = SerializationHelper.Decode (stream, out dw);
                    DrawingFlags flags = (DrawingFlags)dw;
                    da.DrawingFlags = flags;
                    maximumStreamSize -= cb;
                }
                else if (KnownIds.RasterOperation == guid)
                {
                    uint ropSize = GuidList.GetDataSizeIfKnownGuid(KnownIds.RasterOperation);
                    if (ropSize == 0)
                    {
                        throw new InvalidOperationException(StrokeCollectionSerializer. ISFDebugMessage("ROP data size was not found"));
                    }

                    byte[] data = new byte[ropSize];
                    stream.ReadExactly(data);

                    if (data != null && data.Length > 0)
                    {
                        //data[0] holds the allowable values of 0-255
                        rasterOperation = Convert.ToUInt32(data[0]);
                    }

                    maximumStreamSize -= ropSize;
                }
                else if (KnownIds.CurveFittingError == guid)
                {
                    cb = SerializationHelper.Decode (stream, out dw);
                    da.FittingError = (int)dw;
                    maximumStreamSize -= cb;

View on GitHub (pinned to 81131a70a4)