Package Package Package Package Class

Definition

Provides information about a package.

public : sealed class Package : IPackage, IPackage2, IPackage3, IPackage4, IPackage5, IPackageWithMetadatapublic sealed class Package : IPackage, IPackage2, IPackage3, IPackage4, IPackage5, IPackageWithMetadataPublic NotInheritable Class Package Implements IPackage, IPackage2, IPackage3, IPackage4, IPackage5, IPackageWithMetadata// You can use this class in JavaScript.
Attributes
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

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

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// You can use this property in JavaScript.
Value
Package Package Package Package

The package.

Remarks

Important

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

See Also

Dependencies Dependencies Dependencies Dependencies

Gets the packages on which the current package depends.

public : IVectorView<Package> Dependencies { get; }public IReadOnlyList<Package> Dependencies { get; }Public ReadOnly Property Dependencies As IReadOnlyList<Package>// You can use this property in JavaScript.
Value
IVectorView<Package> IReadOnlyList<Package> IReadOnlyList<Package> IReadOnlyList<Package>

The packages on which the current package depends.

Examples

// Get the app package
Package currentPackage = Package.Current;

// Get a list of dependencies for the app package. This includes all resource packages, framework packages, and optional packages.
IReadOnlyList<Package> dependencies = currentPackage.Dependencies;

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.

See Also

Description Description Description Description

Gets the description of the package.

public : PlatForm::String Description { get; }public string Description { get; }Public ReadOnly Property Description As string// You can use this property in JavaScript.
Value
PlatForm::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 Package.Current, this property returns an empty string ("").

See Also

DisplayName DisplayName DisplayName DisplayName

Gets the display name of the package.

public : PlatForm::String DisplayName { get; }public string DisplayName { get; }Public ReadOnly Property DisplayName As string// You can use this property in JavaScript.
Value
PlatForm::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 Package.Current, this property returns an empty string ("").

See Also

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// You can use this property in JavaScript.
Value
PackageId PackageId PackageId PackageId

The package identity.

See Also

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 DateTimeOffset InstallDate { get; }Public ReadOnly Property InstallDate As DateTimeOffset// You can use this property in JavaScript.
Value
DateTime DateTimeOffset DateTimeOffset DateTimeOffset

The date the application package was installed on the user's phone.

Remarks

Windows Phone 8

If you acquire the Package instance by using the Windows.ApplicationModel.Package.Current property, getting the InstallDate property raises an InvalidCastException. If you want to get the InstallDate property, acquire the Package instance by using the Windows.Phone.Management.Deployment.InstallationManager.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 DateTimeOffset InstalledDate { get; }Public ReadOnly Property InstalledDate As DateTimeOffset// You can use this property in JavaScript.
Value
DateTime DateTimeOffset DateTimeOffset DateTimeOffset

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

See Also

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// You can use this property in JavaScript.
Value
StorageFolder StorageFolder StorageFolder StorageFolder

The location of the installed package.

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.

See Also

IsBundle IsBundle IsBundle IsBundle

Indicates whether the package is a bundle package.

public : PlatForm::Boolean IsBundle { get; }public bool IsBundle { get; }Public ReadOnly Property IsBundle As bool// You can use this property in JavaScript.
Value
PlatForm::Boolean 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.

See Also

IsDevelopmentMode IsDevelopmentMode IsDevelopmentMode IsDevelopmentMode

Indicates whether the package is installed in development mode.

public : PlatForm::Boolean IsDevelopmentMode { get; }public bool IsDevelopmentMode { get; }Public ReadOnly Property IsDevelopmentMode As bool// You can use this property in JavaScript.
Value
PlatForm::Boolean 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.

See Also

IsFramework IsFramework IsFramework IsFramework

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

public : PlatForm::Boolean IsFramework { get; }public bool IsFramework { get; }Public ReadOnly Property IsFramework As bool// You can use this property in JavaScript.
Value
PlatForm::Boolean bool bool bool

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

See Also

IsOptional IsOptional IsOptional IsOptional

Indicates whether the package is optional.

public : PlatForm::Boolean IsOptional { get; }public bool IsOptional { get; }Public ReadOnly Property IsOptional As bool// You can use this property in JavaScript.
Value
PlatForm::Boolean bool bool bool

Returns true if the package is optional; false otherwise.

Additional features and requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)

Examples

// Get the main app package
Package currentPackage = Package.Current;

// Get a list of dependencies for the main package. This includes all resource packages, framework packages, and optional packages.
IReadOnlyList<Package> dependencies = currentPackage.Dependencies;

foreach (Package package in dependencies.Where(_ => _.IsOptional))
{
    // Iterate through a list of the optional packages
}

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 : PlatForm::Boolean IsResourcePackage { get; }public bool IsResourcePackage { get; }Public ReadOnly Property IsResourcePackage As bool// You can use this property in JavaScript.
Value
PlatForm::Boolean 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.

See Also

Logo Logo Logo Logo

Gets the logo of the package.

public : Uri Logo { get; }public Uri Logo { get; }Public ReadOnly Property Logo As Uri// You can use this property in JavaScript.
Value
Uri Uri Uri Uri

The logo 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 Package.Current, this property will throw an exception.

See Also

PublisherDisplayName PublisherDisplayName PublisherDisplayName PublisherDisplayName

Gets the publisher display name of the package.

public : PlatForm::String PublisherDisplayName { get; }public string PublisherDisplayName { get; }Public ReadOnly Property PublisherDisplayName As string// You can use this property in JavaScript.
Value
PlatForm::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 Package.Current, this property returns an empty string ("").

See Also

SignatureKind SignatureKind SignatureKind SignatureKind

How the app package is signed.

public : PackageSignatureKind SignatureKind { get; }public PackageSignatureKind SignatureKind { get; }Public ReadOnly Property SignatureKind As PackageSignatureKind// You can use this property in JavaScript.
Additional features and requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)

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// You can use this property in JavaScript.
Value
PackageStatus PackageStatus PackageStatus PackageStatus

The current status of the package for the user.

See Also

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<IVectorView<AppListEntry>> GetAppListEntriesAsync()public IAsyncOperation<IReadOnlyList<AppListEntry>> GetAppListEntriesAsync()Public Function GetAppListEntriesAsync() As IAsyncOperation( Of IReadOnlyListAppListEntry )// You can use this method in JavaScript.
Returns
IAsyncOperation<IVectorView<AppListEntry>> IAsyncOperation<IReadOnlyList<AppListEntry>> IAsyncOperation<IReadOnlyList<AppListEntry>> IAsyncOperation<IReadOnlyList<AppListEntry>>

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

GetContentGroupAsync(String) GetContentGroupAsync(String) GetContentGroupAsync(String) GetContentGroupAsync(String)

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

public : IAsyncOperation<PackageContentGroup> GetContentGroupAsync(PlatForm::String name)public IAsyncOperation<PackageContentGroup> GetContentGroupAsync(String name)Public Function GetContentGroupAsync(name As String) As IAsyncOperation( Of PackageContentGroup )// You can use this method in JavaScript.
Parameters
name
PlatForm::String String String 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.

Additional features and requirements
Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v4)

GetContentGroupsAsync() GetContentGroupsAsync() GetContentGroupsAsync() GetContentGroupsAsync()

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<IVector<PackageContentGroup>> GetContentGroupsAsync()public IAsyncOperation<IList<PackageContentGroup>> GetContentGroupsAsync()Public Function GetContentGroupsAsync() As IAsyncOperation( Of IListPackageContentGroup )// You can use this method in JavaScript.
Returns
IAsyncOperation<IVector<PackageContentGroup>> IAsyncOperation<IList<PackageContentGroup>> IAsyncOperation<IList<PackageContentGroup>> IAsyncOperation<IList<PackageContentGroup>>

A list of package content group objects.

Additional features and requirements
Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v4)

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 : PlatForm::String GetThumbnailToken()public string GetThumbnailToken()Public Function GetThumbnailToken() As string// You can use this method in JavaScript.
Returns
PlatForm::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(String) Launch(String) Launch(String) Launch(String)

Windows Phone only. Launches the specified application.

public : void Launch(PlatForm::String parameters)public void Launch(String parameters)Public Function Launch(parameters As String) As void// You can use this method in JavaScript.
Parameters
parameters
PlatForm::String String String 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 method only works if it is called from a Windows Phone Silverlight app.

SetInUseAsync(Boolean) SetInUseAsync(Boolean) SetInUseAsync(Boolean) SetInUseAsync(Boolean)

Sets whether the package is in use or not.

public : IAsyncOperation<PlatForm::Boolean> SetInUseAsync(bool inUse)public IAsyncOperation<bool> SetInUseAsync(Boolean inUse)Public Function SetInUseAsync(inUse As Boolean) As IAsyncOperation( Of bool )// You can use this method in JavaScript.
Parameters
inUse
bool Boolean Boolean Boolean

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

Returns

True indicates that the operation to set whether the package is in use or not was successful; false otherwise.

Additional features and requirements
Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v4)

Remarks

This API specifies whether the app is using an optional package. With this information the system can determine whether servicing the optional package will require shutting down the app. This provides a better user experience because the app can manage 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(IIterable) StageContentGroupsAsync(IIterable) StageContentGroupsAsync(IIterable) StageContentGroupsAsync(IIterable)

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

public : IAsyncOperation<IVector<PackageContentGroup>> StageContentGroupsAsync(IIterable<PlatForm::String> names)public IAsyncOperation<IList<PackageContentGroup>> StageContentGroupsAsync(IEnumerable<String> names)Public Function StageContentGroupsAsync(names As IEnumerable<String>) As IAsyncOperation( Of IListPackageContentGroup )// You can use this method in JavaScript.
Parameters
names
IIterable<PlatForm::String> IEnumerable<String> IEnumerable<String> IEnumerable<String>

The names of the content groups to stage.

Returns
IAsyncOperation<IVector<PackageContentGroup>> IAsyncOperation<IList<PackageContentGroup>> IAsyncOperation<IList<PackageContentGroup>> IAsyncOperation<IList<PackageContentGroup>>

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

Additional features and requirements
Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v4)

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 PackageCatalog.PackageContentGroupStaging to observe staging progress.

Be sure to check PackageContentGroup.State 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(IIterable, Boolean) StageContentGroupsAsync(IIterable, Boolean) StageContentGroupsAsync(IIterable, Boolean) StageContentGroupsAsync(IIterable, Boolean)

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<IVector<PackageContentGroup>> StageContentGroupsAsync(IIterable<PlatForm::String> names, bool moveToHeadOfQueue)public IAsyncOperation<IList<PackageContentGroup>> StageContentGroupsAsync(IEnumerable<String> names, Boolean moveToHeadOfQueue)Public Function StageContentGroupsAsync(names As IEnumerable<String>, moveToHeadOfQueue As Boolean) As IAsyncOperation( Of IListPackageContentGroup )// You can use this method in JavaScript.
Parameters
names
IIterable<PlatForm::String> IEnumerable<String> IEnumerable<String> IEnumerable<String>

The names of the content groups to stage.

moveToHeadOfQueue
bool Boolean Boolean Boolean

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

Returns
IAsyncOperation<IVector<PackageContentGroup>> IAsyncOperation<IList<PackageContentGroup>> IAsyncOperation<IList<PackageContentGroup>> IAsyncOperation<IList<PackageContentGroup>>

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

Additional features and requirements
Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v4)

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 PackageCatalog.PackageContentGroupStaging to observe staging progress.

Be sure to check PackageContentGroup.State 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<PlatForm::Boolean> VerifyContentIntegrityAsync()public IAsyncOperation<bool> VerifyContentIntegrityAsync()Public Function VerifyContentIntegrityAsync() As IAsyncOperation( Of bool )// You can use this method in JavaScript.
Returns

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

Additional features and requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)

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.

See Also