Share via


PackageCatalog.RemoveOptionalPackagesAsync(IIterable<String>) Method

Definition

Removes installed optional app packages from the user account.

public:
 virtual IAsyncOperation<PackageCatalogRemoveOptionalPackagesResult ^> ^ RemoveOptionalPackagesAsync(IIterable<Platform::String ^> ^ optionalPackageFamilyNames) = RemoveOptionalPackagesAsync;
/// [Windows.Foundation.Metadata.RemoteAsync]
IAsyncOperation<PackageCatalogRemoveOptionalPackagesResult> RemoveOptionalPackagesAsync(IIterable<winrt::hstring> const& optionalPackageFamilyNames);
[Windows.Foundation.Metadata.RemoteAsync]
public IAsyncOperation<PackageCatalogRemoveOptionalPackagesResult> RemoveOptionalPackagesAsync(IEnumerable<string> optionalPackageFamilyNames);
function removeOptionalPackagesAsync(optionalPackageFamilyNames)
Public Function RemoveOptionalPackagesAsync (optionalPackageFamilyNames As IEnumerable(Of String)) As IAsyncOperation(Of PackageCatalogRemoveOptionalPackagesResult)

Parameters

optionalPackageFamilyNames

IIterable<String>

IEnumerable<String>

IIterable<Platform::String>

IIterable<winrt::hstring>

A list of optional package family name strings.

Returns

The result of removing the optional package in the form of: PackageCatalogRemoveOptionalPackagesResult.

Attributes

Windows requirements

Device family
Windows 10 Fall Creators Update (introduced in 10.0.16299.0)
API contract
Windows.Foundation.UniversalApiContract (introduced in v5.0)

Examples

This sample demonstrates removing all of the optional packages from a main app package.

public async void RemoveOptionalPackages() 
{ 
    // Create a list of the optional package family names
    List<string> optionalPackageList = new List<string>(); 
    foreach (var package in Windows.ApplicationModel.Package.Current.Dependencies) 
    { 
        if (package.IsOptional) 
        { 
            optionalPackageList.Add(package.Id.FamilyName); 
        } 
    } 

    // Remove the optional packages from the list    
    PackageCatalog catalog = Windows.ApplicationModel.PackageCatalog.OpenForCurrentPackage(); 
    var removalResult = await catalog.RemoveOptionalPackagesAsync(optionalPackageList); 
    if (removalResult.ExtendedError != null) 
    { 
        throw removalResult.ExtendedError; 
    } 
}

Remarks

A package family name can be found in the FamilyName property of the PackageId.

Applies to