WP7 app version
Asked Answered
F

2

12

A Windows Phone 7 app, it seems, has two places with version number - one in AssemblyInfo.cs (via AssemblyVersion/AssemblyFileVersion attributes), the other is WMAppManifest.xml. Those two seem uncorrelated - changing one does not affect the other. The Marketplace, it seems, uses the one from the manifest - can someone please confirm this?

The real question is - how do I retrieve the one from manifest programmatically to display on the About screen?

Faircloth answered 15/4, 2011 at 17:0 Comment(0)
E
28

The WmAppManifest.xml number is in use. First two digits are relevant for Marketplace (it is checked when you do the update) next two are for your internal usage.

This is a regular XML file, open it as a XDocument and parse it. An example.

EDIT: the example is extraneous. For just the version, use:

string Version = XDocument.Load("WMAppManifest.xml")
    .Root.Element("App").Attribute("Version").Value;
Enmity answered 15/4, 2011 at 18:8 Comment(4)
Thanks. "First two" and "next two" - what do you mean? In the manifest there's only Version, AppPlatformVersion is something completely different.Faircloth
Version="1.3.0.0" 1.3 is valid for the marketplace 0.0 is for you onlyEnmity
The relevant info is that the manifest goes to the device as is (unprocessed), and is easily available as an XML file in run-time. That is not an immediately obvious design.Faircloth
This line of code just might have saved me hours! It works with Unity, just in case anyone requires it.Eastsoutheast
S
1

To get App Version from "WMappManifest.xml", this solution might be a bit more efficient than lukas solution:

For WP7:

var xmlReaderSettings = new XmlReaderSettings
{
    XmlResolver = new XmlXapResolver()
};
using (var xmlReader = XmlReader.Create("WMAppManifest.xml", xmlReaderSettings))
{
    xmlReader.ReadToDescendant("App");
    return xmlReader.GetAttribute("Version");
}

For WP8:

using (var stream = new FileStream("WMAppManifest.xml", FileMode.Open, FileAccess.Read))
{
    string appVersion = XElement.Load(stream).Element("App").Attribute("Version").Value;
}
Sig answered 30/4, 2014 at 12:19 Comment(2)
I don't think efficiency matters much for the About screen.Faircloth
I don't think the answer was specific to the About screen, but specific to how to get Version number.Elvyn

© 2022 - 2024 — McMap. All rights reserved.