{"record":{"id":"e4d938bbaa393d0c","repo":"dotnet/wpf","slug":"sr-invaliddocumentpropertyvarianttype-vt","errorCode":null,"errorMessage":"SR.InvalidDocumentPropertyVariantType (vt)","messagePattern":"SR\\.InvalidDocumentPropertyVariantType \\(vt\\)","errorType":"exception","errorClass":"FileFormatException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/IO/Packaging/StorageBasedPackageProperties.cs","lineNumber":579,"sourceCode":"                            int nLen = ansiString.Length;\n\n                            byte[] byteArray = new byte[nLen];\n                            Marshal.Copy(pszVal, byteArray, 0, nLen);\n\n                            obj = UTF8Encoding.UTF8.GetString(byteArray);\n                            break;\n\n                        case VARTYPE.VT_FILETIME:\n                            //\n                            // DateTime doesn't have a conversion from FILETIME. It has a\n                            // misleadingly named \"FromFileTime\" method that actually wants\n                            // a long. So...\n                            //\n                            obj = new Nullable<DateTime>(DateTime.FromFileTime(vals[0].union.hVal));\n                            break;\n\n                        default:\n                            throw new FileFormatException(\n                                        SR.Format(SR.InvalidDocumentPropertyVariantType, vals[0].vt));\n                    }\n                }\n                finally\n                {\n                    // \"by design\" ignored return value\n                    SafeNativeCompoundFileMethods.SafePropVariantClear(ref vals[0]);\n                }\n            }\n            else if (hresult == SafeNativeCompoundFileConstants.S_FALSE)\n            {\n                // Do nothing -- return the null object reference.\n            }\n            else\n            {\n                SecurityHelper.ThrowExceptionForHR(hresult);\n            }\n","sourceCodeStart":561,"sourceCodeEnd":597,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/IO/Packaging/StorageBasedPackageProperties.cs#L561-L597","documentation":"FileFormatException with message InvalidDocumentPropertyVariantType(vt) thrown by GetOleProperty when the stored OLE property variant type is valid enough to read but falls outside the set of VARTYPEs the conversion switch handles (string, int, short, bool, filetime, etc.). The reader cannot convert the value to a CLR type and reports the raw vt.","triggerScenarios":"Reading a package property whose stored vt is an unhandled variant (e.g. VT_ARRAY, VT_VARIANT, VT_BLOB, VT_CY) for the given propId — the switch in GetOleProperty hits its default case.","commonSituations":"Custom or exotic property sets written by non-Microsoft producers; properties promoted by document management systems into the summary-information stream with unusual types.","solutions":["Re-save the file with a mainstream producer to rewrite properties as standard variant types.","Remove the offending custom property from the document.","Catch FileFormatException around PackageProperties access and fall back to defaults.","Read the raw property set yourself if the exotic type is meaningful to you."],"exampleFix":"// before\nvar creator = pkg.PackageProperties.Creator; // throws on unhandled vt\n// after\nstring creator = null;\ntry { creator = pkg.PackageProperties.Creator; }\ncatch (FileFormatException) { /* unsupported vt */ }","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { value = pkg.PackageProperties.Subject; }\ncatch (FileFormatException) { value = null; /* unsupported stored vt */ }","preventionTips":["Normalize documents through a re-save pipeline before metadata extraction","Strip exotic custom properties from ingested files","Centralize property reads behind a safe accessor with fallbacks"],"tags":["fileformatexception","ole-properties","vartype","metadata"],"backgroundTag":"unsupported-dtype","analyzedSha":"81131a70a4c573cd62748a5c36908fc4d662daa9","analyzedAt":"2026-09-14T10:12:48.479Z","contentChangedAt":"2026-09-14T10:12:48.479Z","schemaVersion":2},"datasetVersion":"2026-09-22T01:17:13.364Z"}