locked
Reading package.appxmanifest file from the code

    Question

  • Hi,

    I want to read package.appxmanifest from my java script. I tried to access the file using xhr but it failing to read the file. Please help me.

    Here is my sample code to read the file

    var packagemanifestURL = 'ms-appx:///package.appxmanifest';
    
    function getBuildVersion() {
        WinJS.xhr({ url: packagemanifestURL }).then(
                 function (result) { // on success                   
                     var xmlDocument = new Windows.Data.Xml.Dom.XmlDocument();
                     xmlDocument.loadXml(result.responseText);
                     var packageVersion;
    
                     packageVersion = xmlDocument.selectNodes('/Package/Identity');
                     if (packageVersion !== null) {
                         document.getElementById("version").innerHTML = "Version:"+ packageVersion[0].innerText;
                         
                     }           
                 },
                 function (args) { // on failure
                     new Windows.UI.Popups.MessageDialog("Failed to load data");
                 }        
                 );
    }


    Thanks and Regards, Jagadish Dharanikota

    Wednesday, November 07, 2012 9:49 AM

Answers

  • if its about the version number check:

    var package = Windows.ApplicationModel.Package;


    Microsoft Certified Solutions Developer - Windows Store Apps Using C#

    Wednesday, November 07, 2012 9:43 PM

  • Hi Jagadish,

    The .appmanifest file is a metadata file used for packaging and deploying your windows store application. It is not intended for accessing from the windows store application itself(at runtime).

    As suggested by Dave smits, if you want to access some basic information about the package in your application code, you should use the "Windows.ApplicationModel.Package.current" property to access the object representing the current application's package. And it contains some child properties including some package information:

    #Package.Current | current property (Windows)
    http://msdn.microsoft.com/en-us/library/windows/apps/windows.applicationmodel.package.current.aspx

    #PackageId class (Windows)
    http://msdn.microsoft.com/en-us/library/windows/apps/windows.applicationmodel.packageid.aspx


    Please remember to mark the replies as answers if they help and unmark them if they provide no help. Putting communities in your palms. Launch the browser on your phone now, type aka.ms/msforums and get connected!

    Thursday, November 08, 2012 2:45 AM
    Moderator

All replies

  • if its about the version number check:

    var package = Windows.ApplicationModel.Package;


    Microsoft Certified Solutions Developer - Windows Store Apps Using C#

    Wednesday, November 07, 2012 9:43 PM

  • Hi Jagadish,

    The .appmanifest file is a metadata file used for packaging and deploying your windows store application. It is not intended for accessing from the windows store application itself(at runtime).

    As suggested by Dave smits, if you want to access some basic information about the package in your application code, you should use the "Windows.ApplicationModel.Package.current" property to access the object representing the current application's package. And it contains some child properties including some package information:

    #Package.Current | current property (Windows)
    http://msdn.microsoft.com/en-us/library/windows/apps/windows.applicationmodel.package.current.aspx

    #PackageId class (Windows)
    http://msdn.microsoft.com/en-us/library/windows/apps/windows.applicationmodel.packageid.aspx


    Please remember to mark the replies as answers if they help and unmark them if they provide no help. Putting communities in your palms. Launch the browser on your phone now, type aka.ms/msforums and get connected!

    Thursday, November 08, 2012 2:45 AM
    Moderator
  • Thanq Dave and Steven. It helped me  :)

    Thanks and Regards, Jagadish Dharanikota

    Thursday, November 08, 2012 4:05 AM