Floating FB popout byF5debug

Package Information in Windows Store Application – Day 8


imageIn this article we are going to see how to retrieve the package information in a Windows Store application. In Windows Store app development we can come across development cases to get the information of the package like the identity of the package and the location of the package being installed etc.. Windows Store SDK has a list of API that are used to retrieve the package information and the account information that can be used while developing the application. To retrieve the package information we are going to use the Package class API that uses the properties to list down the identity of several package properties like Name, Version, Architecture, Resources Info, Publisher Info, Name and Framework information. In our earlier article we have seen how to use the Charm Bar option for incorporating the Privacy Policy statement listed for the end users. Here let us see the steps on using the Package API to get the Package information.                 [more]

How to get the Package Information?

As discussed above the Package Class API has a list of methods and properties which are used to get the information about the package and the location of the package. Below are the list of methods and properties associated with the Package Class

S No




1 Launch Method Launches the Specific application, but its limited to Windows Phone only.
2 Current Property Gets the current application package information
3 ID Property Gets the current application package identity
4 InstallDate Property Gets the current application package installed date, but its restricted to Windows Phone only
5 InstalledLocation Property Gets the current application package installed location.
6 Dependencies Property Gets the list of dependencies that are associated with the current package
7 IsFramework Property This property is used as a indicator that if the other packages can use this package as a reference.


Now its time to write some code and get the application package information, to start with Open Visual Studio 2012 IDE in administrator mode and Create a new Project for Windows Store with C# and XAML as a code base with a valid project name as shown in the screen below. I would suggest you to read my previous article on how to create your first Windows Store application (Developing your first Windows Store App in C# and XAML - Day 3) which will provide some insights and step by step approach on starting the IDE.

We can select the template as per the requirement, please read the article Selecting a right Template and Language for your Windows Store App - Day 2 which provides some insights on which template an be selected for your requirement. Once the project is created we can see a list of default files and folders added to the solution, refer to the previous article to understand the usage of each file. Once we selected the appropriate template we can see the files and folders available in the solution explorer as shown in the screen below.


Open MainPage.xaml file and add few controls basically a Button which is used to trigger a event to call the Package API class and get the information, once we get the information we can showcase the details in a Textblock so lets use this control as well. Once we placed the 2 controls the xaml code looks like below.



<Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
        <Button Content="Get Package Information" FontSize="30" HorizontalAlignment="Left" Margin="103,72,0,0" VerticalAlignment="Top" Height="87" Width="546" Click="Button_Click_1"/>
        <TextBlock HorizontalAlignment="Left" x:Name="txtPackageInfo" FontSize="30" Margin="103,266,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Height="414" Width="1019"/>



Now go to the code behind, i.e. MainPage.Xaml.cs and write the below using statement which has the Package API reference class to get the information of the package.



using Windows.ApplicationModel;


Now let us add the below code in the button click event which creates an instance of Package API class and get the information of the package with the help of the properties that are listed above.



private void Button_Click_1(object sender, RoutedEventArgs e)
            Package package = Package.Current;
            PackageId packageId = package.Id;
            Windows.Storage.StorageFolder insLocation = Package.Current.InstalledLocation;

            txtPackageInfo.Text = String.Format("Name: \"{0}\"\n" + "ResourceId: \"{1}\"\n" + "Publisher: \"{2}\"\n" + "PublisherId: \"{3}\"\n" + "FullName: \"{4}\"\n" +
                                                 "FamilyName: \"{5}\"\n" + "InstalledLocation: \"{6}\"\n" + "IsFramework: {7}", packageId.Name, packageId.ResourceId, packageId.Publisher,
                                                 packageId.PublisherId, packageId.FullName, packageId.FamilyName, insLocation.Path, package.IsFramework);


Now build and execute the application and we get the package information and the application location listed as shown in the screen below.




So in this article we have seen how to use the Package API class to collect the information of the package and the application deploy location that can be used across in the Windows Store application development. So in the upcoming article we will see how we can enhance and use the Windows Store development capabilities one by one and successfully build an application to ship it to the Windows Store.

About Author: Karthikeyan Anbarasan, Microsoft MVP (Most Valuable Professional) in ASP.NET/IIS Architecture. He is the Founder and Chief Editor of the www.f5debug.net website and has authored books on Windows Phone and Business Intelligence(SSIS). He is also a Passionate Speaker and a Blogger on Microsoft Technologies.

You can Join Me On: Facebook, Twitter, Google Plus, LinkedIn

Add comment

  Country flag

  • Comment
  • Preview

Recent Posts

Random Posts

Most Viewed

URL Shortner

Create your own short urls!!!

Site Counter

free counters


This is a personal weblog. The opinions expressed here represent my own and not those of my employer. For accuracy and official reference refer to MSDN/ TechNet. I have documented my personal experience on this blog.

Protected by Copyscape Web Plagiarism Finder

Site Meter