{"record":{"id":"68d8234a73d90fc4","repo":"beeradmoore/dlss-swapper","slug":"could-not-find-any-application-nodes-in-appmanifestfile","errorCode":null,"errorMessage":"Could not find any Application nodes in {appManifestFile}","messagePattern":"Could not find any Application nodes in (.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"src/Data/Xbox/XboxGame.cs","lineNumber":57,"sourceCode":"            return;\n        }\n\n        var appManifestFile = Path.Combine(InstallPath, \"appxmanifest.xml\");\n        if (File.Exists(appManifestFile))\n        {\n            try\n            {\n                var doc = new XmlDocument();\n                doc.Load(appManifestFile);\n\n                var nsmgr = new XmlNamespaceManager(doc.NameTable);\n                string ns = doc.DocumentElement?.NamespaceURI ?? string.Empty;\n                nsmgr.AddNamespace(\"ns\", ns);\n\n                var applicationNodes = doc.SelectNodes(\"//ns:Applications/ns:Application\", nsmgr);\n                if (applicationNodes is null)\n                {\n                    throw new System.Exception($\"Could not find any Application nodes in {appManifestFile}\");\n                }\n\n                foreach (XmlNode appNode in applicationNodes)\n                {\n                    var appId = appNode.Attributes?[\"Id\"]?.Value ?? string.Empty;\n                    if (string.IsNullOrWhiteSpace(appId))\n                    {\n                        continue;\n                    }\n\n                    ApplicationId = appId;\n                }\n            }\n            catch (Exception err)\n            {\n                Logger.Error(err, $\"Could not load ApplicationId for {PlatformId}\");\n            }\n        }","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/beeradmoore/dlss-swapper/blob/ab9b1e2d4bb04187c48fe58eeea06c2b0ea71fbb/src/Data/Xbox/XboxGame.cs#L39-L75","documentation":"XboxGame.LoadApplicationId parses an Xbox game's appmanifest.xml and selects //ns:Applications/ns:Application nodes to read the game's application Id. The thrown message fires when the XPath query returns null — meaning the manifest contains no Application entries. Note the source checks `applicationNodes is null`, which only happens in edge XML cases; an empty node list would skip the foreach silently, so this throw indicates an unexpected/invalid manifest shape.","triggerScenarios":"Calling LoadApplicationId on an appmanifest.xml whose <Applications> element is missing, is empty, uses an unexpected namespace (so the ns: prefix does not match), or is a legacy/different manifest schema without Application nodes.","commonSituations":"Xbox app / Game Pass manifest schema changes after Microsoft Store updates; Xbox games installed to a non-standard location with a truncated or corrupted manifest; scanning a folder that is not actually an Xbox package install; namespace mismatches between the document and the injected ns prefix.","solutions":["Verify the path passed in points to a valid appmanifest.xml inside the game's Xbox package folder (not a placeholder or partial download).","Confirm the manifest's xmlns matches the namespace added to the XmlNamespaceManager; log doc.DocumentElement.NamespaceURI and adjust the XPath if it differs.","Make the XPath resilient: select both namespaced and non-namespaced forms (//ns:Applications/ns:Application | //Applications/Application).","If Microsoft changed the schema, update the XPath to the new element names and re-test against a freshly installed game.","Reinstall/repair the game via the Xbox app if the manifest is genuinely missing the Applications section."],"exampleFix":"// before\nvar applicationNodes = doc.SelectNodes(\"//ns:Applications/ns:Application\", nsmgr);\nif (applicationNodes is null)\n    throw new System.Exception($\"Could not find any Application nodes in {appManifestFile}\");\n// after\nvar applicationNodes = doc.SelectNodes(\"//ns:Applications/ns:Application\", nsmgr)\n    ?? doc.SelectNodes(\"//Applications/Application\");\nif (applicationNodes is null || applicationNodes.Count == 0)\n    throw new System.Exception($\"Could not find any Application nodes in {appManifestFile}\");\n","handlingStrategy":"validation","validationCode":"if (!File.Exists(appManifestFile)) throw new FileNotFoundException(\"appmanifest.xml missing\", appManifestFile);\nvar doc = new XmlDocument(); doc.Load(appManifestFile);\nbool hasApplications = doc.SelectNodes(\"//ns:Applications/ns:Application\", nsmgr)?.Count > 0\n    || doc.SelectNodes(\"//Applications/Application\")?.Count > 0;\nif (!hasApplications) { /* skip game / log warning */ }","typeGuard":"static bool HasApplicationNodes(XmlDocument doc, XmlNamespaceManager nsmgr)\n    => doc?.DocumentElement != null\n       && (doc.SelectNodes(\"//ns:Applications/ns:Application\", nsmgr)?.Count > 0\n           || doc.SelectNodes(\"//Applications/Application\")?.Count > 0);","tryCatchPattern":"try\n{\n    var gameId = XboxGame.LoadApplicationId(manifestPath);\n}\ncatch (Exception ex) when (ex.Message.StartsWith(\"Could not find any Application nodes\"))\n{\n    Logger.Warn(ex, \"Skipping game with invalid manifest: \" + manifestPath);\n}","preventionTips":["Validate that the manifest path is inside a real Xbox package install before parsing.","Log the manifest root namespace and dump the XML when parsing fails to catch schema changes early.","Support both namespaced and non-namespaced XPath lookups.","Never assume one game's bad manifest should fail the whole library scan."],"tags":["xml","xbox","game-pass","manifest-parsing"],"backgroundTag":"schema-validation-failed","analyzedSha":"ab9b1e2d4bb04187c48fe58eeea06c2b0ea71fbb","analyzedAt":"2026-09-15T05:25:32.979Z","contentChangedAt":"2026-09-15T05:25:32.979Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}