WP7 app version

只愿长相守 提交于 2019-12-05 14:28:30

问题


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?


回答1:


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;



回答2:


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


来源:https://stackoverflow.com/questions/5680018/wp7-app-version

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!