{"record":{"id":"5bd20c8164171e54","repo":"QL-Win/QuickLook","slug":"appxmanifest-xml-not-found","errorCode":null,"errorMessage":"AppxManifest.xml not found","messagePattern":"AppxManifest\\.xml not found","errorType":"exception","errorClass":"InvalidDataException","httpStatus":null,"severity":"error","filePath":"QuickLook.Plugin/QuickLook.Plugin.AppViewer/PackageParsers/Appx/AppxReader.cs","lineNumber":99,"sourceCode":"        Open();\n    }\n\n    public AppxReader(string path)\n    {\n        zip = new ZipFile(path);\n        Open();\n    }\n\n    public void Dispose()\n    {\n        zip?.Close();\n        zip = null;\n    }\n\n    private void Open()\n    {\n        ZipEntry entry = zip.GetEntry(\"AppxManifest.xml\")\n            ?? throw new InvalidDataException(\"AppxManifest.xml not found\");\n\n        XmlDocument xml = new() { XmlResolver = null };\n        xml.Load(zip.GetInputStream(entry));\n\n        XmlElement packageNode = xml.DocumentElement;\n\n        // Identity\n        {\n            XmlElement identityNode = packageNode[\"Identity\"];\n\n            if (identityNode != null)\n            {\n                Name = identityNode.Attributes[\"Name\"]?.Value;\n                Version = identityNode.Attributes[\"Version\"]?.Value;\n                Publisher = identityNode.Attributes[\"Publisher\"]?.Value;\n\n                Match m = Regex.Match(Publisher, @\"CN=([^,]*),?\");\n                if (m.Success) Publisher = m.Groups[1].Value;","sourceCodeStart":81,"sourceCodeEnd":117,"githubUrl":"https://github.com/QL-Win/QuickLook/blob/cb5d9c429c81d9796fac469da2a68efb5626946d/QuickLook.Plugin/QuickLook.Plugin.AppViewer/PackageParsers/Appx/AppxReader.cs#L81-L117","documentation":"Thrown by AppxReader.Open when the zip archive has no entry named 'AppxManifest.xml'. Every valid .appx/.msix package must contain this manifest at the archive root. Its absence indicates the file is not an app package, is corrupt, or uses a non-standard layout. The error is an InvalidDataException.","triggerScenarios":"Constructing new AppxReader(stream) or new AppxReader(path) on a non-.appx zip, a corrupt package, or a bundle (.appxbundle) whose top-level entries are nested .appx files rather than a flat AppxManifest.xml.","commonSituations":"Passing an .appxbundle to AppxReader (should use AppxBundleReader); a truncated download; a repackaged or stripped app package; an .msix with an unexpected manifest location.","solutions":["Verify the zip contains 'AppxManifest.xml' before constructing AppxReader.","If the file is an .appxbundle, use AppxBundleReader which locates the inner .appx and its manifest automatically.","Check the file extension/content and reject non-app packages early with a clear message.","Catch InvalidDataException and report the file as unsupported."],"exampleFix":"// before\nvar reader = new AppxReader(path);\n\n// after\nusing var zip = new ICSharpCode.SharpZipLib.Zip.ZipFile(path);\nbool hasManifest = zip.GetEntry(\"AppxManifest.xml\") != null;\nzip.Close();\nif (!hasManifest)\n    throw new InvalidDataException($\"{path} is not a valid .appx (AppxManifest.xml missing).\");\nvar reader = new AppxReader(path);","handlingStrategy":"validation","validationCode":"// Confirm the zip contains AppxManifest.xml before constructing AppxReader.\npublic static bool IsAppx(string path)\n{\n    try\n    {\n        using var zip = new ICSharpCode.SharpZipLib.Zip.ZipFile(path);\n        return zip.GetEntry(\"AppxManifest.xml\") != null;\n    }\n    catch { return false; }\n}","typeGuard":null,"tryCatchPattern":"try { var reader = new AppxReader(path); }\ncatch (InvalidDataException ex) when (ex.Message.Contains(\"AppxManifest\"))\n{\n    // Not a valid .appx; if it's a bundle, use AppxBundleReader instead.\n}","preventionTips":["Use AppxBundleReader for .appxbundle files and AppxReader for single .appx.","Verify the manifest entry exists before constructing the reader.","Catch InvalidDataException and route to the correct reader."],"tags":["appx","zip","manifest","invaliddata","csharp"],"backgroundTag":null,"analyzedSha":"cb5d9c429c81d9796fac469da2a68efb5626946d","analyzedAt":"2026-08-13T11:51:01.370Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}