Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get app version in Windows Phone?

In C# one can use System.Version.Assembly to get the version of a running app. However this doesn't appear to exist in Silverlight for Windows Phone. Is there an alternative?

like image 637
henry Avatar asked Sep 30 '10 17:09

henry


People also ask

How do you update apps on a Windows Phone?

On your phone, open the Store and tap Settings (hamburger menu) located at the top left of the screen. Then tap Downloads and updates from the list. Then, on the next screen, tap the Check for Updates button, wait while updates are found, and select the Update all link. Of course, you can update apps individually, too.

Can you still get apps for Windows Phone?

The Windows Phone Store provides access to the latest music, apps, games and more to all Microsoft account holders. To access, tap the Windows Store tile.

Does Windows Phone app store still work?

After December 16, 2019, the Store in Windows Phone 8.1 will no longer be available for downloading new apps or reinstalling previously downloaded apps. Users who reset or reimage their phones will not be able to recover previously downloaded apps after this date.


3 Answers

You can use the GetExecutingAssembly method and the AssemblyName class to find this information.


  var nameHelper = new AssemblyName(Assembly.GetExecutingAssembly().FullName);    var version = nameHelper.Version;   var full = nameHelper.FullName;   var name = nameHelper.Name; 

like image 181
Walt Ritscher Avatar answered Sep 30 '22 18:09

Walt Ritscher


If you have moved over to Windows Phone 8, you can simply use the newer PackageId class:

var version = Package.Current.Id.Version;
like image 21
Magnus Johansson Avatar answered Sep 30 '22 19:09

Magnus Johansson


I don't how @henry accepted the answer because all answers are talking about Dll version but when one is talking about getting the version of windows phone app that means version of app on the market. I don't know about others but I really don't care about the version of dll and also I use market version to label the source in source control.

When a developer upload XAP on the market he/she specifies the version of XAP which can be different then the dll version, while processing Market reads information from WMAppManifest.xml file and write backs the version you specify on the XAP submission page.

So the desired version is available in WMappManifest.xml file which you can read by XmlReader like following;

    public static string GetAppVersion()
    {
        var xmlReaderSettings = new XmlReaderSettings
        {
            XmlResolver = new XmlXapResolver()
        };

        using (var xmlReader = XmlReader.Create("WMAppManifest.xml", xmlReaderSettings))
        {
            xmlReader.ReadToDescendant("App");

            return xmlReader.GetAttribute("Version");
        }
    }

Here is sample WMAppManifest.xml

<Deployment xmlns="http://schemas.microsoft.com/windowsphone/2012/deployment" AppPlatformVersion="8.0">
  <DefaultLanguage xmlns="" code="en-US"/>
  <App xmlns="" ProductID="{cc18507d-0de0-42d6-8b0f-05addeafd21e}" Title="CaledosLab.Phone.ContosoLogTest" RuntimeType="Silverlight" Version="1.0.0.0" Genre="apps.normal"  Author="CaledosLab.Phone.ContosoLogTest author" Description="Sample description" Publisher="CaledosLab.Phone.ContosoLogTest" PublisherID="{a204adfc-7718-4c4a-afb4-c1c39ec50d30}">
  </App>
</Deployment>

So you can read whatever information you want from App xml tag the same way as we read version from app tag. e.g. publisher Id or Product Id

like image 28
Mubashar Avatar answered Sep 30 '22 19:09

Mubashar