Package Package Package Package Class

Provides information about a package.

Syntax

Declaration

public sealed class Packagepublic sealed class PackagePublic NotInheritable Class Package

Remarks

Although Package is supported in desktop apps, some members of this class are supported only in Windows Store app. The remarks section will indicate whether a member has any restrictions on its behavior.

Properties summary

Gets the package for the current app.

Gets the packages on which the current package depends.

Gets the description of the package.

Gets the display name of the package.

Gets the package identity of the current package.

Windows Phone only. Gets the date the application package was installed on the user's phone.

Gets the date on which the application package was installed or last updated.

Gets the location of the installed package.

Indicates whether the package is a bundle package.

Indicates whether the package is installed in development mode.

Indicates whether other packages can declare a dependency on this package.

Indicates whether the package is optional.

Indicates whether the package is a resource package.

Gets the logo of the package.

Gets the publisher display name of the package.

How the app package is signed.

Get the current status of the package for the user.

Methods summary

Enumerates the packaged apps on the device. Only packaged apps that are registered to the current user are returned.

Prerelease. Provides information about the package content group such as its state, name, whether it is required, and so on.

Prerelease. Provides information about all of the package content groups in the app and their state, name, whether they are required, and so on.

Windows Phone only. Returns a token that can be used to retrieve the thumbnail image associated with this application package.

Windows Phone only. Launches the specified application.

Prerelease. Sets whether the package is in use or not.

Prerelease. Put the packages in the specified content groups into the staging queue.

Prerelease. Put the packages in the specified content groups into the staging queue; optionally placing the content groups at the head of the queue.

Ensures that the package has not been modified or tampered with before being loaded.

Properties

  • Current
    Current
    Current
    Current

    Gets the package for the current app.

    public static Package Current { get; }public static Package Current { get; }Public Static ReadOnly Property Current As Package

    Property Value

    Remarks

    Important

    Although Package is supported in desktop apps, this member is supported only in Windows Store app. To access a package object from a desktop app, use PackageManager.

  • Dependencies
    Dependencies
    Dependencies
    Dependencies

    Gets the packages on which the current package depends.

    public IVectorView<Package> Dependencies { get; }public IVectorView<Package> Dependencies { get; }Public ReadOnly Property Dependencies As IVectorView<Package>

    Property Value

    • The packages on which the current package depends.

    Remarks

    Important

    Although Package is supported in desktop apps, this member is supported only in Windows Store app. To access a package's dependencies from a desktop app, use GetPackageInfo.

  • Description
    Description
    Description
    Description

    Gets the description of the package.

    public string Description { get; }public string Description { get; }Public ReadOnly Property Description As string

    Property Value

    • string
      string
      string
      string

      The description of the package.

    Remarks

    Important

    This property is only supported for Windows Store app. If you call this property on an instance of a package that was created by any mechanism other than Current, this property returns an empty string ("").

  • DisplayName
    DisplayName
    DisplayName
    DisplayName

    Gets the display name of the package.

    public string DisplayName { get; }public string DisplayName { get; }Public ReadOnly Property DisplayName As string

    Property Value

    • string
      string
      string
      string

      The display name.

    Remarks

    Important

    This property is only supported for Windows Store app. If you call this property on an instance of a package that was created by any mechanism other than Current, this property returns an empty string ("").

  • Id
    Id
    Id
    Id

    Gets the package identity of the current package.

    public PackageId Id { get; }public PackageId Id { get; }Public ReadOnly Property Id As PackageId

    Property Value

  • InstallDate
    InstallDate
    InstallDate
    InstallDate

    Windows Phone only. Gets the date the application package was installed on the user's phone.

    public DateTime InstallDate { get; }public DateTime InstallDate { get; }Public ReadOnly Property InstallDate As DateTime

    Property Value

    Remarks

    Windows Phone 8

    If you acquire the Package instance by using the Current property, getting the InstallDate property raises an InvalidCastException. If you want to get the InstallDate property, acquire the Package instance by using the FindPackagesForCurrentPublisher() method.

    
    using Windows.ApplicationModel;
    
    IEnumerable<Package> packages = Windows.Phone.Management.Deployment.InstallationManager.FindPackagesForCurrentPublisher();
    Package package = packages.First();
    DateTimeOffset packageInstallDate = package.InstallDate;
    

    Windows 10

    This API is not implemented and will throw an exception if called.

  • InstalledDate
    InstalledDate
    InstalledDate
    InstalledDate

    Gets the date on which the application package was installed or last updated.

    public DateTime InstalledDate { get; }public DateTime InstalledDate { get; }Public ReadOnly Property InstalledDate As DateTime

    Property Value

  • InstalledLocation
    InstalledLocation
    InstalledLocation
    InstalledLocation

    Gets the location of the installed package.

    public StorageFolder InstalledLocation { get; }public StorageFolder InstalledLocation { get; }Public ReadOnly Property InstalledLocation As StorageFolder

    Property Value

    Remarks

    There are several other ways to refer to the a file in a package.

    • You can just begin a URI with a "/" to refer to the package root. For example: <img src="/file.png" alt="" />
    • You can use the "ms-appx:///" protocol. For example:<img src="ms-appx://packageFullName/file.png" alt="" />
    • You can also omit the package name to let the system fill in the domain, as shown here:

    <img src="ms-appx:///file.png" alt="" /> For more info about how to refer to files in an app's package, see How to load file resources.

  • IsBundle
    IsBundle
    IsBundle
    IsBundle

    Indicates whether the package is a bundle package.

    public bool IsBundle { get; }public bool IsBundle { get; }Public ReadOnly Property IsBundle As bool

    Property Value

    • bool
      bool
      bool
      bool

      A Boolean value that indicates whether the package is a bundle package. TRUE indicates that the package is a bundle package; otherwise FALSE.

  • IsDevelopmentMode
    IsDevelopmentMode
    IsDevelopmentMode
    IsDevelopmentMode

    Indicates whether the package is installed in development mode.

    public bool IsDevelopmentMode { get; }public bool IsDevelopmentMode { get; }Public ReadOnly Property IsDevelopmentMode As bool

    Property Value

    • bool
      bool
      bool
      bool

      A Boolean value that indicates whether the package is installed in development mode. TRUE indicates that the package is installed in development mode; otherwise FALSE.

  • IsFramework
    IsFramework
    IsFramework
    IsFramework

    Indicates whether other packages can declare a dependency on this package.

    public bool IsFramework { get; }public bool IsFramework { get; }Public ReadOnly Property IsFramework As bool

    Property Value

    • bool
      bool
      bool
      bool

      True if other packages can declare a dependency on this package; otherwise false.

  • IsOptional
    IsOptional
    IsOptional
    IsOptional

    Indicates whether the package is optional.

    public bool IsOptional { get; }public bool IsOptional { get; }Public ReadOnly Property IsOptional As bool

    Property Value

    • bool
      bool
      bool
      bool

      Returns true if the package is optional; false otherwise.

    Remarks

    Optional packages are dependent on another package that must be installed first. For example a map application may have optional geographic area packages.

  • IsResourcePackage
    IsResourcePackage
    IsResourcePackage
    IsResourcePackage

    Indicates whether the package is a resource package.

    public bool IsResourcePackage { get; }public bool IsResourcePackage { get; }Public ReadOnly Property IsResourcePackage As bool

    Property Value

    • bool
      bool
      bool
      bool

      A Boolean value that indicates whether the package is a resource package. TRUE indicates that the package is a resource package; otherwise FALSE.

  • PublisherDisplayName
    PublisherDisplayName
    PublisherDisplayName
    PublisherDisplayName

    Gets the publisher display name of the package.

    public string PublisherDisplayName { get; }public string PublisherDisplayName { get; }Public ReadOnly Property PublisherDisplayName As string

    Property Value

    • string
      string
      string
      string

      The publisher display name.

    Remarks

    Important

    This property is only supported for Windows Store app. If you call this property on an instance of a package that was created by any mechanism other than Current, this property returns an empty string ("").

  • SignatureKind
    SignatureKind
    SignatureKind
    SignatureKind

    How the app package is signed.

    public PackageSignatureKind SignatureKind { get; }public PackageSignatureKind SignatureKind { get; }Public ReadOnly Property SignatureKind As PackageSignatureKind

    Property Value

  • Status
    Status
    Status
    Status

    Get the current status of the package for the user.

    public PackageStatus Status { get; }public PackageStatus Status { get; }Public ReadOnly Property Status As PackageStatus

    Property Value

Methods

  • GetAppListEntriesAsync()
    GetAppListEntriesAsync()
    GetAppListEntriesAsync()
    GetAppListEntriesAsync()

    Enumerates the packaged apps on the device. Only packaged apps that are registered to the current user are returned.

    public IAsyncOperation<AppListEntry>> GetAppListEntriesAsync()public IAsyncOperation<AppListEntry>> GetAppListEntriesAsync()Public Function GetAppListEntriesAsync() As IAsyncOperation( Of AppListEntry )

    Returns

    • A list of packaged apps along with their display name, description, and logo.

  • GetContentGroupAsync(System.String)
    GetContentGroupAsync(System.String)
    GetContentGroupAsync(System.String)
    GetContentGroupAsync(System.String)

    Prerelease. Provides information about the package content group such as its state, name, whether it is required, and so on.

    public IAsyncOperation<PackageContentGroup> GetContentGroupAsync(System.String name)public IAsyncOperation<PackageContentGroup> GetContentGroupAsync(System.String name)Public Function GetContentGroupAsync(name As System.String) As IAsyncOperation( Of PackageContentGroup )

    Parameters

    • name
      System.String
      System.String
      System.String
      System.String

      The name of the content group to get.

    Returns

    • A PackageContentGroup that contains information such as whether the content group is required, its state, the package associated with the content group, and so on. Returns Null if the named content group is not part of this package.

  • GetContentGroupsAsync()
    GetContentGroupsAsync()
    GetContentGroupsAsync()
    GetContentGroupsAsync()

    Prerelease. Provides information about all of the package content groups in the app and their state, name, whether they are required, and so on.

    public IAsyncOperation<PackageContentGroup>> GetContentGroupsAsync()public IAsyncOperation<PackageContentGroup>> GetContentGroupsAsync()Public Function GetContentGroupsAsync() As IAsyncOperation( Of PackageContentGroup )

    Returns

    • A list of package content group objects.

    Remarks

    The returned collection may be empty if the package does not contain any content groups.

  • GetThumbnailToken()
    GetThumbnailToken()
    GetThumbnailToken()
    GetThumbnailToken()

    Windows Phone only. Returns a token that can be used to retrieve the thumbnail image associated with this application package.

    public string GetThumbnailToken()public string GetThumbnailToken()Public Function GetThumbnailToken() As string

    Returns

    • string
      string
      string
      string

      A token that can be used to retrieve the thumbnail image associated with this application package.

    Remarks

    Use the GetSharedFileName method passing the token returned by this method to retrieve the thumbnail image associated with this application package.

  • Launch(System.String)
    Launch(System.String)
    Launch(System.String)
    Launch(System.String)

    Windows Phone only. Launches the specified application.

    public void Launch(System.String parameters)public void Launch(System.String parameters)Public Function Launch(parameters As System.String) As void

    Parameters

    • parameters
      System.String
      System.String
      System.String
      System.String

      The navigation URI that specifies the page to launch and optional parameters. Use an empty string to specify the default page for the app.

    Remarks

    The Launch parameter has the same format as the NavigationUri format. The following table shows some examples:

    ScenarioLaunch parameterExample
    You just want to launch the app with the default page.Specify an empty string.pkg.Launch("");
    You want to launch to a particular XAML page.Start with a forward slash (/) followed by the XAML page name.pkg.Launch("/Page1.xaml");
    You want to pass parameters to the default page.Start with a question mark (?) followed by name/value pairs. Use an equal sign (=) between the name and value. Separate multiple name/value pairs with an ampersand (&).pkg.Launch("?content=1234&param2=test");
    You want to launch to a particular XAML page and pass in parameters.Use a combination of the previous two examples.pkg.Launch("/Page1.xaml?content=1234&param2=test ");
    Important

    The Launch(System.String) method only works if it is called from a Windows Phone Silverlight app.

  • SetInUseAsync(System.Boolean)
    SetInUseAsync(System.Boolean)
    SetInUseAsync(System.Boolean)
    SetInUseAsync(System.Boolean)

    Prerelease. Sets whether the package is in use or not.

    public IAsyncOperation<bool> SetInUseAsync(System.Boolean inUse)public IAsyncOperation<bool> SetInUseAsync(System.Boolean inUse)Public Function SetInUseAsync(inUse As System.Boolean) As IAsyncOperation( Of bool )

    Parameters

    • inUse
      System.Boolean
      System.Boolean
      System.Boolean
      System.Boolean

      True to specify that the package is in use; false otherwise.

    Returns

    • True indicates that the operation was successful; false otherwise.

    Remarks

    This API provides a way to indicate whether the app is using an optional package. With this information the system can determine whether servicing the optional package requires shutting down the app or not. This provides a better user experience because the app can mitigate when it is shut down for optional package updates or removals.

    By default, all optional packages are in use. Servicing an optional package causes the app to shut down. To avoid shutting down the app when an optional package that is not being used is updated or removed, call this API with inUse set to false.

  • StageContentGroupsAsync(Windows.Foundation.Collections.IIterable{System.String})
    StageContentGroupsAsync(Windows.Foundation.Collections.IIterable{System.String})
    StageContentGroupsAsync(Windows.Foundation.Collections.IIterable{System.String})
    StageContentGroupsAsync(Windows.Foundation.Collections.IIterable{System.String})

    Prerelease. Put the packages in the specified content groups into the staging queue.

    public IAsyncOperation<PackageContentGroup>> StageContentGroupsAsync(Windows.Foundation.Collections.IIterable{System.String} names)public IAsyncOperation<PackageContentGroup>> StageContentGroupsAsync(Windows.Foundation.Collections.IIterable{System.String} names)Public Function StageContentGroupsAsync(names As Windows.Foundation.Collections.IIterable{System.String}) As IAsyncOperation( Of PackageContentGroup )

    Parameters

    • names

      The names of the content groups to stage.

    Returns

    • A list of PackageContentGroup objects for each content group specified by the names parameter.

    Remarks

    This function completes when all requested groups are staged. The returned list may contain a null element if the named group in that position does not exist. Use PackageContentGroupStaging to observe staging progress.

    Be sure to check PackageContentGroupState to verify that the group was successfully staged. Referencing files in a group that is not fully staged may result in unexpected application behavior. Content groups return to the PackageContentGroupState.NotStaged state if the staging operation cannot be completed.

  • StageContentGroupsAsync(Windows.Foundation.Collections.IIterable{System.String},System.Boolean)
    StageContentGroupsAsync(Windows.Foundation.Collections.IIterable{System.String},System.Boolean)
    StageContentGroupsAsync(Windows.Foundation.Collections.IIterable{System.String},System.Boolean)
    StageContentGroupsAsync(Windows.Foundation.Collections.IIterable{System.String},System.Boolean)

    Prerelease. Put the packages in the specified content groups into the staging queue; optionally placing the content groups at the head of the queue.

    public IAsyncOperation<PackageContentGroup>> StageContentGroupsAsync(Windows.Foundation.Collections.IIterable{System.String} names,System.Boolean moveToHeadOfQueue)public IAsyncOperation<PackageContentGroup>> StageContentGroupsAsync(Windows.Foundation.Collections.IIterable{System.String} names,System.Boolean moveToHeadOfQueue)Public Function StageContentGroupsAsync(names As Windows.Foundation.Collections.IIterable{System.String},moveToHeadOfQueue As System.Boolean) As IAsyncOperation( Of PackageContentGroup )

    Parameters

    • names

      The names of the content groups to stage.

    • moveToHeadOfQueue
      System.Boolean
      System.Boolean
      System.Boolean
      System.Boolean

      True to move the content group to the head of the staging queue; false otherwise.

    Returns

    • A list of PackageContentGroup objects for each content group specified by the names parameter.

    Remarks

    This function completes when all requested groups are staged. The returned list may contain a null element if the named group in that position does not exist. Use PackageContentGroupStaging to observe staging progress.

    Be sure to check PackageContentGroupState to verify that the group was successfully staged. Referencing files in a group that is not fully staged may result in unexpected application behavior. Content groups return to the PackageContentGroupState.NotStaged state if the staging operation cannot be completed.

  • VerifyContentIntegrityAsync()
    VerifyContentIntegrityAsync()
    VerifyContentIntegrityAsync()
    VerifyContentIntegrityAsync()

    Ensures that the package has not been modified or tampered with before being loaded.

    public IAsyncOperation<bool> VerifyContentIntegrityAsync()public IAsyncOperation<bool> VerifyContentIntegrityAsync()Public Function VerifyContentIntegrityAsync() As IAsyncOperation( Of bool )

    Returns

    • true - the package has not been modified; false otherwise.

    Remarks

    This function only verifies that the package's contents have not been modified. It does not verify the package's status, origin, and so on.

Device family

Windows 10 (introduced v10.0.10240.0)

API contract

Windows.Foundation.UniversalApiContract (introduced v1)

Attributes

Windows.Foundation.Metadata.DualApiPartitionAttribute
Windows.Foundation.Metadata.MarshalingBehaviorAttribute
Windows.Foundation.Metadata.ContractVersionAttribute
Windows.Foundation.Metadata.ThreadingAttribute
Windows.Foundation.Metadata.StaticAttribute

Details

Assembly

Windows.ApplicationModel.dll