MddAddPackageDependency function (msixdynamicdependency.h)

Adds a run-time reference for the framework package dependency you created earlier by using the MddTryCreatePackageDependency method, with the specified options. After this method successfully returns, your app can activate types and use content from the framework package.

Syntax

HRESULT MddAddPackageDependency(
  PCWSTR                         packageDependencyId,
  INT32                          rank,
  MddAddPackageDependencyOptions options,
  MDD_PACKAGEDEPENDENCY_CONTEXT  *packageDependencyContext,
  PWSTR                          *packageFullName
) noexcept;

Parameters

packageDependencyId

Type: PCWSTR

The ID of the package dependency to be resolved and added to the invoking process' package graph. This parameter must match a package dependency defined by using the TryCreatePackageDependency function for the calling user or the system (via the ScopeIsSystem option), or else an error is returned.

rank

Type: INT32

The rank to use to add the resolved package to the caller's package graph. For more information, see the remarks.

options

Type: MddAddPackageDependencyOptions

The options to apply when adding the package dependency.

packageDependencyContext

Type: PACKAGEDEPENDENCY_CONTEXT*

The handle of the added package dependency. This handle is valid until it is passed to RemovePackageDependency.

packageFullName

Type: PCWSTR*

The full name of the package to which the dependency has been resolved. Use the HeapAlloc function to allocate memory for this parameter, and use HeapFree to deallocate the memory.

Return value

Type: HRESULT

If the function succeeds it returns ERROR_SUCCESS. Otherwise, the function returns an error code. The possible error codes include the following.

Return code Description
E_INVALIDARG The packageDependencyId or packageDependencyContext parameter is NULL on input.

Remarks

Calling this method resolves the framework package dependency to a specific package on the system. It also informs the OS that the framework package is in active use and to handle any version updates in a side-by-side manner (effectively delay uninstalling or otherwise servicing the older version until after your app is done using it). Package resolution is specific to a user and can return different values for different users on a system.

Each successful MddAddPackageDependency call adds the resolved package to the calling process' package graph, even if already present. There is no duplicate detection or filtering applied by the API (that is, multiple references from a package is not harmful). After resolution is complete, the package dependency stays resolved for that user until the last reference across all processes for that user is removed via MddRemovePackageDependency or the process is terminated. Successful calls to this method change the generation ID value returned by MddGetGenerationId.

After this method successfully returns, your app can activate types and use content from the framework package until MddRemovePackageDependency is called.

If multiple packages are present in the package graph with the same rank as the call to MddAddPackageDependency, the resolved package is (by default) added after others of the same rank. To add a package before others of the same rank, specify PrependIfRankCollision for the options parameter.

For more information, see Use the dynamic dependency API to reference MSIX packages at run time.

Requirements

Requirement Value
Minimum supported client Windows 10, version 1809 (with Windows App SDK 1.0 or later)
Header msixdynamicdependency.h

See also

MddRemovePackageDependency

MddTryCreatePackageDependency

Use the dynamic dependency API to reference MSIX packages at run time