{"record":{"id":"6a5878d302da7daa","repo":"dotnet/wpf","slug":"sr-xpsvalidatingloaderunsupportedmimetype","errorCode":null,"errorMessage":"SR.XpsValidatingLoaderUnsupportedMimeType","messagePattern":"SR\\.XpsValidatingLoaderUnsupportedMimeType","errorType":"exception","errorClass":"FileFormatException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/FixedSchema.cs","lineNumber":324,"sourceCode":"                {\n                    return true;\n                }\n            }\n            return false;\n        }\n\n        public virtual string [] ExtractUriFromAttr(string attrName, string attrValue)\n        {\n            return null;\n        }\n\n        public static XpsSchema GetSchema(ContentType mimeType)\n        {\n            XpsSchema schema = null;\n\n            if (!_schemas.TryGetValue(mimeType, out schema))\n            {\n                throw new FileFormatException(SR.XpsValidatingLoaderUnsupportedMimeType);\n            }\n\n            return schema;\n        }\n\n        private static readonly Dictionary<ContentType, XpsSchema> _schemas = new Dictionary<ContentType, XpsSchema>(new ContentType.StrongComparer());\n        private Hashtable _requiredResourceMimeTypes = new Hashtable(11);\n    }\n\n    internal class XpsS0Schema:XpsSchema\n    {\n        // When creating a new schema, add a static member to XpsSchemaValidator to register it.\n        protected\n        XpsS0Schema()\n        {\n        }\n\n        public override XmlReaderSettings GetXmlReaderSettings()","sourceCodeStart":306,"sourceCodeEnd":342,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Documents/FixedSchema.cs#L306-L342","documentation":"XpsSchema.GetSchema looks up a static registry of known XPS Content Types (FixedDocumentSequence, FixedDocument, FixedPage, ResourceDictionary). If the supplied ContentType is not one of the registered XPS schema MIME types, a FileFormatException is thrown because the validating loader cannot find a schema to validate the part against.","triggerScenarios":"Passing a ContentType to GetSchema (directly or via the XPS validating loader when opening a package) whose type/subtype is not one of application/vnd.ms-package.xps-* — e.g. a random XML part, an image part, or a typo'd MIME type in [Content_Types].xml.","commonSituations":"Custom OPC packages that include XML parts which are not XPS markup; hand-edited [Content_Types].xml with an incorrect MIME string; attempts to validate arbitrary markup parts with the XPS loader; case/format mistakes in the Content Type string.","solutions":["Only feed parts whose Content Type is one of the supported application/vnd.ms-package.xps-* types to the XPS validating loader.","Fix the part's Content Type in [Content_Types].xml (or via part.ContentType) to match the actual XPS markup type.","Exclude non-XPS parts from validation and load them through the regular packaging APIs instead.","Check for typos/case errors in the MIME type string; use ContentType.StrongComparer semantics (exact type/subtype)."],"exampleFix":"// before\npart.ContentType = \"application/xps-fixedpage+xml\"; // wrong MIME\n// after\npart.ContentType = \"application/vnd.ms-package.xps-fixedpage+xml\";","handlingStrategy":"validation","validationCode":"static readonly HashSet<string> Supported = new(StringComparer.OrdinalIgnoreCase) {\n    \"application/vnd.ms-package.xps-fixeddocumentsequence+xml\",\n    \"application/vnd.ms-package.xps-fixeddocument+xml\",\n    \"application/vnd.ms-package.xps-fixedpage+xml\",\n    \"application/vnd.ms-package.xps-resourcedictionary+xml\" };\nif (!Supported.Contains(part.ContentType))\n    throw new InvalidOperationException($\"Part {part.Uri} has unsupported Content Type {part.ContentType}\");","typeGuard":"static bool IsXpsSchemaPart(PackagePart p) =>\n    p.ContentType.StartsWith(\"application/vnd.ms-package.xps-\", StringComparison.OrdinalIgnoreCase) && p.ContentType.EndsWith(\"+xml\", StringComparison.OrdinalIgnoreCase);","tryCatchPattern":"try { var schema = XpsSchema.GetSchema(contentType); ValidateWith(schema); }\ncatch (FileFormatException) { /* part is not an XPS schema part: route to generic OPC handling */ }","preventionTips":["Only pass XPS markup parts to the XPS validating loader; handle images/fonts via normal Packaging APIs.","Fix MIME strings in [Content_Types].xml and keep them exact.","Never rely on extension-based MIME guessing for XPS parts."],"tags":["xps","mime-type","content-type","schema"],"backgroundTag":"unsupported-operation","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"}