dotnet/wpf · error · ArgumentException

InkSerializedFormat operation failed.

Error message

InkSerializedFormat operation failed.

What it means

AlgoModule.DecompressPacketData decompresses Ink Serialized Format (ISF) packet data. It validates the inputs first: a null input buffer throws ArgumentNullException, surfaced by the caller as a generic 'InkSerializedFormat operation failed' ArgumentException context — here the first guard (input null) corresponds to the line-150 region. It indicates ISF packet data being decompressed is missing or null.

Solutions

  1. Ensure the input byte[] is non-null and comes from a complete ISF stream
  2. Validate ISF data integrity before deserialization (stream fully read, length > 0)
  3. Catch ArgumentException around deserialization and treat the ink as unreadable
  4. Re-export or re-save the ink data from the source application

Example fix

// before
algo.DecompressPacketData(readBuffer, outBuffer);
// after
if (readBuffer != null && readBuffer.Length >= 2) algo.DecompressPacketData(readBuffer, outBuffer); else throw new InvalidDataException("ISF packet data missing");
Defensive patterns

Strategy: validation

Validate before calling

if (input == null) throw new ArgumentNullException(nameof(input));
if (input.Length < 2) throw new InvalidDataException("ISF packet data missing or truncated");

Type guard

static bool ValidPacketInput(byte[] b) => b != null && b.Length >= 2;

Try / catch

try { algo.DecompressPacketData(input, output); }
catch (ArgumentException ex) { throw new InvalidDataException("Corrupt ISF packet data", ex); }

Prevention

When it happens

Trigger: Calling DecompressPacketData (directly or via ISF deserialization of a stroke collection) with a null input byte array, i.e. corrupt or absent packet data.

Common situations: Loading truncated or malformed .isf / ink streams; deserializing ink embedded in documents where the packet-data attribute is missing.

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


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

Appendix: source

Thrown at src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Ink/InkSerializedFormat/AlgoModule.cs:150

            }

            // compression / algo data always goes in index 0
            compressedData[0] = compression;
            return compressedData.ToArray();
        }

        /// <summary>
        /// DecompressPacketData - given a compressed byte[], uncompress it to the outputBuffer
        /// </summary>
        /// <param name="input">compressed byte from the ISF stream</param>
        /// <param name="outputBuffer">prealloc'd buffer to write to</param>
        /// <returns></returns>
        internal uint DecompressPacketData(byte[] input, int[] outputBuffer)
        {
            ArgumentNullException.ThrowIfNull(input);
            if (input.Length < 2)
            {
                throw new ArgumentException(StrokeCollectionSerializer.ISFDebugMessage("Input buffer passed was shorter than expected"));
            }
            ArgumentNullException.ThrowIfNull(outputBuffer);
            if (outputBuffer.Length == 0)
            {
                throw new ArgumentException(StrokeCollectionSerializer.ISFDebugMessage("output buffer length was zero"));
            }

            byte compression = input[0];
            uint totalBytesRead = 1; //we just read one
            int inputIndex = 1;
            switch (compression & 0xC0)
            {
                case 0x80://IndexedHuffman
                    {
                        DataXform dtxf = this.HuffModule.FindDtXf(compression);
                        HuffCodec huffCodec = this.HuffModule.FindCodec(compression);
                        totalBytesRead += huffCodec.Uncompress(dtxf, input, inputIndex, outputBuffer);
                        return totalBytesRead;

View on GitHub (pinned to 81131a70a4)