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
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

Gets the package for the current app.

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

The package.

Attributes

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

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>
Value

The packages on which the current package depends.

Attributes

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.

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;
See Also

Description Description Description

Gets the description of the package.

public PlatForm::String Description { get; }public string Description { get; }Public ReadOnly Property Description As string
Value
string string string

The description of the package.

Attributes

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

Gets the display name of the package.

public PlatForm::String DisplayName { get; }public string DisplayName { get; }Public ReadOnly Property DisplayName As string
Value
string string string

The display name.

Attributes

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

Gets the package identity of the current package.

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

The package identity.

Attributes
See Also

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
Value
DateTime DateTime DateTime

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

Attributes

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

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
Value
DateTime DateTime DateTime

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

Attributes

InstalledLocation InstalledLocation InstalledLocation

Gets the location of the installed package.

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

The location of the installed package.

Attributes

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

Indicates whether the package is a bundle package.

public PlatForm::Boolean IsBundle { get; }public bool IsBundle { get; }Public ReadOnly Property IsBundle As bool
Value
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.

Attributes
See Also

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
Value
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.

Attributes
See Also

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
Value
bool bool bool

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

Attributes
See Also

IsOptional IsOptional IsOptional

Indicates whether the package is optional.

public PlatForm::Boolean IsOptional { get; }public bool IsOptional { get; }Public ReadOnly Property IsOptional As bool
Value
bool bool bool

Returns true if the package is optional; false otherwise.

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

Remarks

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

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
}

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
Value
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.

Attributes
See Also

Logo Logo Logo

Gets the logo of the package.

public Uri Logo { get; }public Uri Logo { get; }Public ReadOnly Property Logo As Uri
Value
Uri Uri Uri

The logo of the package.

Attributes

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

Gets the publisher display name of the package.

public PlatForm::String PublisherDisplayName { get; }public string PublisherDisplayName { get; }Public ReadOnly Property PublisherDisplayName As string
Value
string string string

The publisher display name.

Attributes

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

How the app package is signed.

public PackageSignatureKind SignatureKind { get; }public PackageSignatureKind SignatureKind { get; }Public ReadOnly Property SignatureKind As PackageSignatureKind
Attributes
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

Get the current status of the package for the user.

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

The current status of the package for the user.

Attributes

Methods

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<IVectorView<AppListEntry>> GetAppListEntriesAsync()Public Function GetAppListEntriesAsync() As IAsyncOperation( Of IVectorViewAppListEntry )
Returns

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

Attributes

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(String name)public IAsyncOperation<PackageContentGroup> GetContentGroupAsync(String name)Public Function GetContentGroupAsync(name As String) As IAsyncOperation( Of PackageContentGroup )
Parameters
name
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.

Attributes
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()

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<IVector<PackageContentGroup>> GetContentGroupsAsync()Public Function GetContentGroupsAsync() As IAsyncOperation( Of IVectorPackageContentGroup )
Returns

A list of package content group objects.

Attributes
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()

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
Returns
string string string

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

Attributes

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)

Windows Phone only. Launches the specified application.

public void Launch(String parameters)public void Launch(String parameters)Public Function Launch(parameters As String) As void
Parameters
parameters
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.

Attributes

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)

Sets whether the package is in use or not.

public IAsyncOperation<bool> SetInUseAsync(Boolean inUse)public IAsyncOperation<bool> SetInUseAsync(Boolean inUse)Public Function SetInUseAsync(inUse As Boolean) As IAsyncOperation( Of bool )
Parameters
inUse
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.

Attributes
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<String>) StageContentGroupsAsync(IIterable<String>) StageContentGroupsAsync(IIterable<String>)

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

public IAsyncOperation<IVector<PackageContentGroup>> StageContentGroupsAsync(IIterable<String> names)public IAsyncOperation<IVector<PackageContentGroup>> StageContentGroupsAsync(IIterable<String> names)Public Function StageContentGroupsAsync(names As IIterable<String>) As IAsyncOperation( Of IVectorPackageContentGroup )
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.

Attributes
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<String>, Boolean) StageContentGroupsAsync(IIterable<String>, Boolean) StageContentGroupsAsync(IIterable<String>, 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<String> names, Boolean moveToHeadOfQueue)public IAsyncOperation<IVector<PackageContentGroup>> StageContentGroupsAsync(IIterable<String> names, Boolean moveToHeadOfQueue)Public Function StageContentGroupsAsync(names As IIterable<String>, moveToHeadOfQueue As Boolean) As IAsyncOperation( Of IVectorPackageContentGroup )
Parameters
names

The names of the content groups to stage.

moveToHeadOfQueue
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.

Attributes
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()

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.

Attributes
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