开发者

WP7 app version

A Windows Phone 7 app, it seems, has two places with versio开发者_JAVA技巧n 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?


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;


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;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜