Search code examples
windows-runtimewindows-phonewindows-phone-8.1

How to get the version of a Windows Phone 8.1 app in code?


Is it possible to get the version of the app while it's running?

In a Windows desktop application I can get it as follows:

System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;

But GetExecutingAssembly() isn't available in Windows Phone 8.1.

Is there another way?


Solution

  • This is how:

    PackageVersion pv = Package.Current.Id.Version;
    Version version = new Version(Package.Current.Id.Version.Major, 
        Package.Current.Id.Version.Minor, 
        Package.Current.Id.Version.Revision, 
        Package.Current.Id.Version.Build);