locked
How do I read Version Number in WinPhone Silverlight 8.1? RRS feed

  • Question

  • User153793 posted

    I created an IVersion class in my pcl namespace MyApp { public interface IVersion { string GetVersionNumber(); } }

    A Version Class in android [assembly: Dependency(typeof(MyApp.Droid.Version))] namespace MyApp.Droid { public class Version : IVersion { public string GetVersionNumber() { Context context = Forms.Context; PackageManager manager = context.PackageManager; PackageInfo info = manager.GetPackageInfo(context.PackageName, 0); return info.VersionName; } } } A Version class for iOS [assembly: Dependency(typeof(MyApp.iOS.Version))] namespace MyApp.iOS { public class Version : IVersion { public string GetVersionNumber() { string version = NSBundle.MainBundle.InfoDictionary[new NSString("CFBundleShortVersionString")].ToString()+ "."+ NSBundle.MainBundle.InfoDictionary[new NSString("CFBundleVersion")].ToString(); return version; } } } And for Windows Phone Silverligth 8.1 [assembly: Dependency(typeof(MyApp.WinPhone.Version))] namespace MyApp.WinPhone { public class Version : IVersion { public Version() { } public string GetVersionNumber() { string version = ""; //??? return version; } } }

    How can I get the version number from WinPhone?

    Wednesday, September 7, 2016 7:37 PM

Answers

  • User217569 posted

    Do you mean the Application version? If so this may help you.

    string Version = XDocument.Load("WMAppManifest.xml") .Root.Element("App").Attribute("Version").Value;

    Im not completely sure but it may point you in the right direction anyway. I found the awnser here - stackoverflow.com/questions/25768694/wp8-get-current-app-version

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Wednesday, September 7, 2016 7:54 PM

All replies

  • User217569 posted

    Do you mean the Application version? If so this may help you.

    string Version = XDocument.Load("WMAppManifest.xml") .Root.Element("App").Attribute("Version").Value;

    Im not completely sure but it may point you in the right direction anyway. I found the awnser here - stackoverflow.com/questions/25768694/wp8-get-current-app-version

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Wednesday, September 7, 2016 7:54 PM
  • User153793 posted

    Thank you Tony, it worked.

    Wednesday, September 7, 2016 9:26 PM