{"record":{"id":"6bcfe0fe3a7c82a6","repo":"QL-Win/QuickLook","slug":"appxmetadata-appxbundlemanifest-xml-not-found","errorCode":null,"errorMessage":"AppxMetadata/AppxBundleManifest.xml not found","messagePattern":"AppxMetadata/AppxBundleManifest\\.xml not found","errorType":"exception","errorClass":"InvalidDataException","httpStatus":null,"severity":"error","filePath":"QuickLook.Plugin/QuickLook.Plugin.AppViewer/PackageParsers/Appx/AppxBundleReader.cs","lineNumber":71,"sourceCode":"\n    public AppxBundleReader(string path)\n    {\n        Open(new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read));\n    }\n\n    public void Dispose()\n    {\n        appxReader?.Dispose();\n        appxReader = null;\n        zip?.Close();\n        zip = null;\n    }\n\n    private void Open(Stream stream)\n    {\n        zip = new ZipFile(stream);\n        ZipEntry entry = zip.GetEntry(\"AppxMetadata/AppxBundleManifest.xml\")\n           ?? throw new InvalidDataException(\"AppxMetadata/AppxBundleManifest.xml not found\");\n\n        XmlDocument xml = new() { XmlResolver = null };\n        xml.Load(zip.GetInputStream(entry));\n\n        XmlElement bundleNode = xml.DocumentElement;\n\n        // Identity\n        {\n            XmlElement identityNode = bundleNode[\"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":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/QL-Win/QuickLook/blob/cb5d9c429c81d9796fac469da2a68efb5626946d/QuickLook.Plugin/QuickLook.Plugin.AppViewer/PackageParsers/Appx/AppxBundleReader.cs#L53-L89","documentation":"Thrown by AppxBundleReader.Open when the zip archive does not contain an entry named 'AppxMetadata/AppxBundleManifest.xml'. This entry is mandatory in every valid .appxbundle; its absence means the file is not an app bundle, is corrupt, or has an unexpected structure. The error is an InvalidDataException.","triggerScenarios":"Constructing new AppxBundleReader(stream) or new AppxBundleReader(path) on a file that is a plain .appx (not a bundle), a .msix, a zip with unrelated contents, or a corrupt/truncated .appxbundle whose manifest entry is missing or at a different path.","commonSituations":"Passing an .appx (single package) to AppxBundleReader instead of AppxReader; passing an .msix bundle whose manifest path differs; a partially downloaded/corrupt bundle; a repackaged zip that lost the AppxMetadata directory.","solutions":["Confirm the file is actually an .appxbundle (look for AppxMetadata/AppxBundleManifest.xml inside the zip) before constructing AppxBundleReader.","If the file is a single .appx/.msix package, use AppxReader instead.","List zip entries and check for the manifest path; if missing, surface a clear 'not an app bundle' message.","Handle InvalidDataException and fall back to trying AppxReader."],"exampleFix":"// before\nvar reader = new AppxBundleReader(path);\n\n// after\nusing var zip = new ICSharpCode.SharpZipLib.Zip.ZipFile(path);\nbool isBundle = zip.GetEntry(\"AppxMetadata/AppxBundleManifest.xml\") != null;\nzip.Close();\nif (!isBundle)\n    throw new InvalidDataException($\"{path} is not an .appxbundle (manifest missing).\");\nvar reader = new AppxBundleReader(path);","handlingStrategy":"validation","validationCode":"// Confirm the zip contains the bundle manifest before constructing AppxBundleReader.\npublic static bool IsAppxBundle(string path)\n{\n    try\n    {\n        using var zip = new ICSharpCode.SharpZipLib.Zip.ZipFile(path);\n        return zip.GetEntry(\"AppxMetadata/AppxBundleManifest.xml\") != null;\n    }\n    catch { return false; }\n}","typeGuard":null,"tryCatchPattern":"try { var reader = new AppxBundleReader(path); }\ncatch (InvalidDataException ex) when (ex.Message.Contains(\"AppxBundleManifest\"))\n{\n    // Not an .appxbundle; try AppxReader for a single .appx package instead.\n}","preventionTips":["Distinguish .appx (single package) from .appxbundle before choosing the reader.","Verify the manifest entry exists in the zip before constructing the reader.","Catch InvalidDataException and fall back to AppxReader."],"tags":["appx","appxbundle","zip","manifest","invaliddata","csharp"],"backgroundTag":null,"analyzedSha":"cb5d9c429c81d9796fac469da2a68efb5626946d","analyzedAt":"2026-08-13T11:51:01.370Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}