PackageManager.RequestAddPackageAsync 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
重载
RequestAddPackageAsync(Uri, IIterable<Uri>, DeploymentOptions, PackageVolume, IIterable<String>, IIterable<Uri>, IIterable<Uri>) |
在安装应用包 () 之前请求 SmartScreen 检查和用户验证。 此方法提供 packageUrisToInstall 重载来指定要暂存和注册的外部包。 |
RequestAddPackageAsync(Uri, IIterable<Uri>, DeploymentOptions, PackageVolume, IIterable<String>, IIterable<Uri>) |
在安装应用包 () 之前请求 SmartScreen 检查和用户验证。 |
RequestAddPackageAsync(Uri, IIterable<Uri>, DeploymentOptions, PackageVolume, IIterable<String>, IIterable<Uri>, IIterable<Uri>)
public:
virtual IAsyncOperationWithProgress<DeploymentResult ^, DeploymentProgress> ^ RequestAddPackageAsync(Uri ^ packageUri, IIterable<Uri ^> ^ dependencyPackageUris, DeploymentOptions deploymentOptions, PackageVolume ^ targetVolume, IIterable<Platform::String ^> ^ optionalPackageFamilyNames, IIterable<Uri ^> ^ relatedPackageUris, IIterable<Uri ^> ^ packageUrisToInstall) = RequestAddPackageAsync;
/// [Windows.Foundation.Metadata.Overload("RequestAddPackageAndRelatedSetAsync")]
/// [Windows.Foundation.Metadata.RemoteAsync]
IAsyncOperationWithProgress<DeploymentResult, DeploymentProgress> RequestAddPackageAsync(Uri const& packageUri, IIterable<Uri> const& dependencyPackageUris, DeploymentOptions const& deploymentOptions, PackageVolume const& targetVolume, IIterable<winrt::hstring> const& optionalPackageFamilyNames, IIterable<Uri> const& relatedPackageUris, IIterable<Uri> const& packageUrisToInstall);
[Windows.Foundation.Metadata.Overload("RequestAddPackageAndRelatedSetAsync")]
[Windows.Foundation.Metadata.RemoteAsync]
public IAsyncOperationWithProgress<DeploymentResult,DeploymentProgress> RequestAddPackageAsync(System.Uri packageUri, IEnumerable<System.Uri> dependencyPackageUris, DeploymentOptions deploymentOptions, PackageVolume targetVolume, IEnumerable<string> optionalPackageFamilyNames, IEnumerable<System.Uri> relatedPackageUris, IEnumerable<System.Uri> packageUrisToInstall);
function requestAddPackageAsync(packageUri, dependencyPackageUris, deploymentOptions, targetVolume, optionalPackageFamilyNames, relatedPackageUris, packageUrisToInstall)
Public Function RequestAddPackageAsync (packageUri As Uri, dependencyPackageUris As IEnumerable(Of Uri), deploymentOptions As DeploymentOptions, targetVolume As PackageVolume, optionalPackageFamilyNames As IEnumerable(Of String), relatedPackageUris As IEnumerable(Of Uri), packageUrisToInstall As IEnumerable(Of Uri)) As IAsyncOperationWithProgress(Of DeploymentResult, DeploymentProgress)
参数
- dependencyPackageUris
要添加的依赖项包的 URI。 如果没有依赖项包,或者如果已注册依赖项包,则此参数可以为 null。
- deploymentOptions
- DeploymentOptions
DeploymentOptions 枚举中的有效枚举值。
- targetVolume
- PackageVolume
包安装到的卷。
指定要暂存和注册的main捆绑包的可选包系列名称的字符串。
- relatedPackageUris
main捆绑包中应暂存和注册的其他包的 URI。
- packageUrisToInstall
要暂存和注册的其他包 URI 的列表。 这可以包含要安装的外部包的路径。
返回
添加应用包的进度和结果。
- 属性
Windows 要求
设备系列 |
Windows 10, version 1803 (在 10.0.17134.0 中引入)
|
API contract |
Windows.Foundation.UniversalApiContract (在 v6.0 中引入)
|
另请参阅
适用于
RequestAddPackageAsync(Uri, IIterable<Uri>, DeploymentOptions, PackageVolume, IIterable<String>, IIterable<Uri>)
public:
virtual IAsyncOperationWithProgress<DeploymentResult ^, DeploymentProgress> ^ RequestAddPackageAsync(Uri ^ packageUri, IIterable<Uri ^> ^ dependencyPackageUris, DeploymentOptions deploymentOptions, PackageVolume ^ targetVolume, IIterable<Platform::String ^> ^ optionalPackageFamilyNames, IIterable<Uri ^> ^ relatedPackageUris) = RequestAddPackageAsync;
/// [Windows.Foundation.Metadata.RemoteAsync]
IAsyncOperationWithProgress<DeploymentResult, DeploymentProgress> RequestAddPackageAsync(Uri const& packageUri, IIterable<Uri> const& dependencyPackageUris, DeploymentOptions const& deploymentOptions, PackageVolume const& targetVolume, IIterable<winrt::hstring> const& optionalPackageFamilyNames, IIterable<Uri> const& relatedPackageUris);
[Windows.Foundation.Metadata.RemoteAsync]
public IAsyncOperationWithProgress<DeploymentResult,DeploymentProgress> RequestAddPackageAsync(System.Uri packageUri, IEnumerable<System.Uri> dependencyPackageUris, DeploymentOptions deploymentOptions, PackageVolume targetVolume, IEnumerable<string> optionalPackageFamilyNames, IEnumerable<System.Uri> relatedPackageUris);
function requestAddPackageAsync(packageUri, dependencyPackageUris, deploymentOptions, targetVolume, optionalPackageFamilyNames, relatedPackageUris)
Public Function RequestAddPackageAsync (packageUri As Uri, dependencyPackageUris As IEnumerable(Of Uri), deploymentOptions As DeploymentOptions, targetVolume As PackageVolume, optionalPackageFamilyNames As IEnumerable(Of String), relatedPackageUris As IEnumerable(Of Uri)) As IAsyncOperationWithProgress(Of DeploymentResult, DeploymentProgress)
参数
- dependencyPackageUris
要添加的依赖项包的 URI。 如果没有依赖项包,或者如果已注册依赖项包,则此参数可以为 null。
- deploymentOptions
- DeploymentOptions
DeploymentOptions 枚举中的有效枚举值。
- targetVolume
- PackageVolume
包安装到的卷。
指定要暂存和注册的main捆绑包的可选包系列名称的字符串。
- relatedPackageUris
main捆绑包中应暂存和注册的其他包的 URI。
返回
应用包部署的进度和结果。
- 属性
Windows 要求
设备系列 |
Windows 10 Fall Creators Update (在 10.0.16299.0 中引入)
|
API contract |
Windows.Foundation.UniversalApiContract (在 v5.0 中引入)
|
示例
该示例演示如何通过将 RequestAddPackageAsync 挂接到按钮单击处理程序,在 UWP 应用中使用它。 这将调用 SmartScreen 请求 UI 窗口。
public async void OnInstallNowClicked(object sender, RoutedEventArgs args)
{
var packageManager = new PackageManager();
DeploymentOperation result = await packageManager.RequestAddPackageAsync(
this.currentPackageUri,
null /*no dependencies*/,
DeploymentOptions.None,
null /*stage to default package volume*/,
null /*no optional packages*/,
null /*no external packages*/);
if (result.ExtendedErrorCode != null)
{
if (result.ExtendedErrorCode.HResult == 0x80073d01)
{
// SmartScreen blocked the app installation.
}
else
{
// The app installation failed for another reason.
}
}
}