dotnet/wpf · error · ArgumentException
SR.UnknownDocumentProperty (fmtid, propId)
Error message
SR.UnknownDocumentProperty (fmtid, propId)
What it means
ArgumentException with message UnknownDocumentProperty(fmtid, propId) (paramName 'propId') thrown by StorageBasedPackageProperties.GetVtFromPropId when the property-set lookup table has no entry mapping the given fmtid/propId combination to a VARTYPE. vtExpected relies on this mapping, so an unmapped property id cannot be read.
Solutions
- Only request well-known package properties via PackageProperties.
- If supporting custom ids, add a case to GetVtFromPropId returning the correct VARTYPE.
- Use a dedicated OLE property-set library for arbitrary custom properties instead of this mapping.
- Check the fmtid/propId spelling — a wrong constant lookup triggers the default case.
Example fix
// before
vt = GetVtFromPropId(fmtid, (PropertyId)0x9999); // throws
// after
if (Enum.IsDefined(typeof(PropertyId), propId) && IsKnownProperty(fmtid, propId))
vt = GetVtFromPropId(fmtid, propId);
else
return null; // skip unknown property Defensive patterns
Strategy: validation
Validate before calling
if (!Enum.IsDefined(typeof(PropertyId), propId)) return null; // skip unknown property
Try / catch
try { vt = GetVtFromPropId(fmtid, propId); }
catch (ArgumentException ex) when (ex.ParamName == "propId") { return null; /* unmapped property */ } Prevention
- Restrict reads to well-known PackageProperties accessors
- Register any custom propId in the fmtid/propId -> VARTYPE mapping first
- Verify property id constants against the MS-OLEPS specification
When it happens
Trigger: Calling GetOleProperty (via a PackageProperties getter) with a propId that exists in the property stream but is not one of the well-known ids (Title, Subject, Author, Keywords, etc.) handled by the switch — including unknown ids under the SummaryInformation or DocumentSummaryInformation format ids.
Common situations: Extending the properties reader to custom property ids without registering them; files carrying extra properties that internal code iterates and tries to resolve.
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
- SR.InvalidDocumentPropertyType (type)
- SR.InvalidDocumentPropertyVariantType (vt)
- SR.WrongDocumentPropertyVariantType (propId, fmtid, actual…
- ArgumentException(SR.Format(SR.CollectionCannotContainNulls…
- ArgumentException(SR.StringIsNullOrEmpty, nameof(fileName))
AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14).
Data as JSON: /api/errors/ff7288ef712d5ed1.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/IO/Packaging/StorageBasedPackageProperties.cs:824
{
switch (propId)
{
case PropertyId.Title:
case PropertyId.Subject:
case PropertyId.Creator:
case PropertyId.Keywords:
case PropertyId.Description:
case PropertyId.LastModifiedBy:
case PropertyId.Revision:
return VARTYPE.VT_LPSTR;
case PropertyId.LastPrinted:
case PropertyId.DateCreated:
case PropertyId.DateModified:
return VARTYPE.VT_FILETIME;
default:
throw new ArgumentException(
SR.Format(SR.UnknownDocumentProperty, fmtid.ToString(), propId),
nameof(propId)
);
}
}
else if (fmtid == FormatId.DocumentSummaryInformation)
{
switch (propId)
{
case PropertyId.Category:
case PropertyId.Identifier:
case PropertyId.ContentType:
case PropertyId.Language:
case PropertyId.Version:
case PropertyId.ContentStatus:
return VARTYPE.VT_LPSTR;
default:View on GitHub (pinned to 81131a70a4)