How to access Application Manifest (WMAppManifest.xml) file in WP7 App at runtime

 

Very long time and back to work, just for curiosity about how to access “WMAppManifest.xml”; using silverlight c# code in Windows Phone application. In this article we will discuss Application Manifest file called WMAppManifest.xml file and it is available in Properties folder of your project in the Solution Explorer. Manifest file contains details about the application, such as the App ID Title, RuntimeType, Version, Genre, Author, Description, Publisher and the application capabilities.

Here is a ways to read the WMAppManifest.xml file using XML Parse API.

Consider below mentioned code snippet.

private string ReadWMAppManifest()
        {
            string wmData = string.Empty;
            System.Xml.Linq.XElement appxml = System.Xml.Linq.XElement.Load("WMAppManifest.xml");
            var appElement = (from manifestData in appxml.Descendants("App") select manifestData).SingleOrDefault();

            if (appElement != null)
            {
                wmData = "ProductID = " + appElement.Attribute("ProductID").Value + Environment.NewLine;
                
                wmData += "Title = " + appElement.Attribute("Title").Value + Environment.NewLine;
                wmData += "RuntimeType = " + appElement.Attribute("RuntimeType").Value + Environment.NewLine;
                wmData += "Version = " + appElement.Attribute("Version").Value + Environment.NewLine;
                wmData += "Genre = " + appElement.Attribute("Genre").Value + Environment.NewLine;
                wmData += "Author = " + appElement.Attribute("Author").Value + Environment.NewLine;
                wmData += "Description = " + appElement.Attribute("Description").Value + Environment.NewLine;
                wmData += "Publisher = " + appElement.Attribute("Publisher").Value + Environment.NewLine;
            }

            appElement = (from manifestData in appxml.Descendants("PrimaryToken") select manifestData).SingleOrDefault();

            if (appElement != null)
            {
                wmData += "TokenID = " + appElement.Attribute("TokenID").Value + Environment.NewLine;
            }

            return wmData;
        }

 

Download source code here – ReadWMAppManifest

Happy Coding

Thanks for your time.

Advertisements

About Pavan Pareta

My name is Pavan Pareta, I enjoy computers and general technology. I am more interested in the areas of Computer Security, Programming and developing innovative s/w for Windows Mobile and Windows Phone 7. I like MS Technology and support open-source software, because I believe it plays a major role in knowledge sharing and exchange of ideas, which effectively leads to better software. Additionally, I am a follower of the KISS (Keep It Simple Stupid) philosophy. I Love C#.NET and recently I am fall in love with Silverlight :) Introduce to my machine My main workstation is a Intel Pentium Core Duo and my primary operating system is Windows 7.
This entry was posted in Windows Mobile. Bookmark the permalink.

2 Responses to How to access Application Manifest (WMAppManifest.xml) file in WP7 App at runtime

  1. Alvin Christ says:

    This comment has been removed by the author.

  2. Alvin Christ says:

    I was just curious to know about the C# codes and your article helped me. I will keep looking forward for such codes to improve my technical skills.manage my bills online

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s