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
封裝安裝所在的磁碟區。
字串,指定要暫存和註冊主要套件組合的選擇性套件系列名稱。
- relatedPackageUris
主要套件組合中應暫存和註冊之其他套件的 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
封裝安裝所在的磁碟區。
字串,指定要暫存和註冊主要套件組合的選擇性套件系列名稱。
- relatedPackageUris
主要套件組合中應暫存和註冊之其他套件的 URI。
傳回
應用程式套件部署的進度和結果。
- 屬性
Windows 需求
裝置系列 |
Windows 10 Fall Creators Update (已於 10.0.16299.0 引進)
|
API contract |
Windows.Foundation.UniversalApiContract (已於 v5.0 引進)
|
範例
此範例示範如何在 UWP 應用程式中使用 RequestAddPackageAsync,方法是將其連結至按鈕按兩下處理程式。 這會叫用 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.
}
}
}