dotnet/wpf · error · ArgumentException
InvalidDataInISF
Error message
InvalidDataInISF
What it means
While decoding extended properties from an ISF stream, converting the persisted bytes back to a char or char[] threw ArgumentException (bad character data), so the serializer wraps it in a new ArgumentException with SR.InvalidDataInISF. This indicates the ISF payload is corrupt or was not produced with matching type metadata. The original exception is preserved as InnerException.
Solutions
- Validate the ISF source file/stream integrity before loading
- Remove or re-save the offending ExtendedProperty before serializing the ink again
- Inspect ex.InnerException for the underlying decode failure
- Regenerate the ISF from the original ink data if available
Example fix
// before
strokeCollection = new StrokeCollectionReader(isfStream).GetStrokeCollection(); // throws on corrupt data
// after
try
{
strokeCollection = new StrokeCollectionReader(isfStream).GetStrokeCollection();
}
catch (ArgumentException ex) when (ex.InnerException != null)
{
// log ex.InnerException; fall back to re-saving or skipping the bad stroke
} Defensive patterns
Strategy: try-catch
Try / catch
try { strokes = new StrokeCollection(isfStream); }
catch (ArgumentException ex) when (ex.Message.Contains("ISF")) { Log(ex.InnerException); isfStream.Seek(0, SeekOrigin.Begin); /* salvage path */ } Prevention
- Checksum ISF files at write time and verify before load
- Never hand-edit ISF bytes
- Test round-trip serialization of char/char[] extended properties
- Validate third-party ISF in a sandboxed load before production use
When it happens
Trigger: Reading a stroke's ExtendedProperties from ISF whose declared type is char/char[] but the byte payload is not a valid UTF-16 char sequence — e.g. odd byte counts, truncated data, or data written by a non-WPF producer.
Common situations: Hand-edited or third-party-generated ISF; files truncated in transfer; cross-version/cross-platform ISF interchange where the extended property type table disagrees with the payload.
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
- Drawing Attribute tag embedded in ISF stream does not match…
- Invalid ISF data
- Invalid PenTip value found in ISF stream
- Invalid size specified
- ISF Operation Failed
AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14).
Data as JSON: /api/errors/ca3a12dda101fb47.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Ink/InkSerializedFormat/CustomAttributeSerializer.cs:949
break;
}
case (VarEnum.VT_DATE)://7
{
DateTime data = (DateTime)value;
writer.Write(data.ToOADate());
break;
}
default:
{
Debug.Fail("Missing case statement!");
break;
}
}
}
catch (ArgumentException ex)
{
//catches bad char & char[]
throw new ArgumentException(SR.InvalidDataInISF, ex);
}
catch (OverflowException ex)
{
//catches bad DateTime
throw new ArgumentException(SR.InvalidDataInISF, ex);
}
}
}
break;
}
//do nothing in the default case...
}
}
return;
}
}
#endregion // Key/Value pair validation helpers
View on GitHub (pinned to 81131a70a4)