ApplicationDeployment イベント

名前 | 説明 | |
---|---|---|
![]() | CheckForUpdateCompleted | CheckForUpdateAsync の完了時に発生します。 |
![]() | CheckForUpdateProgressChanged | CheckForUpdateAsync の呼び出しで進行状況の更新を使用できる場合に発生します。 |
![]() | DownloadFileGroupCompleted | ファイルのダウンロードが完了すると、メイン アプリケーション スレッドで発生します。 |
![]() | DownloadFileGroupProgressChanged | DownloadFileGroupAsync の呼び出しによって開始されたファイルのダウンロード操作で、ステータス情報を使用できる場合に発生します。 |
![]() | UpdateCompleted | UpdateAsync の呼び出しの結果として、ClickOnce がアプリケーションのアップグレードを完了したときに発生します。 |
![]() | UpdateProgressChanged | UpdateAsync の呼び出しによって開始された更新操作について、ClickOnce に新しいステータス情報がある場合に発生します。 |

ApplicationDeployment クラス
アセンブリ: System.Deployment (system.deployment.dll 内)


配置マニフェストの subscription 要素によって、自動的に更新をチェックしてインストールするように、ClickOnce アプリケーションを構成できます。ただし、一部のアプリケーションでは、更新に対するより細かい制御が必要です。必須の更新はプログラムによってインストールし、オプションの更新の場合はユーザーの都合に合わせてインストールできるようにユーザーに確認を求めるプロンプトを表示できます。配置マニフェストでサブスクリプションの更新を無効にすることにより、アプリケーションの更新ポリシーを完全に制御できます。また、ClickOnce がアプリケーションを定期的に更新できるようにする ApplicationDeployment と組み合わせて、自動サブスクリプションを使用することもできます。ただし、重要な更新がリリースされた直後にダウンロードするには、ApplicationDeployment を使用します。
CheckForUpdate メソッドまたは CheckForUpdateAsync メソッドを使用すると、配置に利用可能な更新があるかどうか調べることができます。後者のメソッドは、正常に完了すると CheckForUpdateCompleted イベントを発生させます。CheckForDetailedUpdate は、更新のバージョン番号や、その更新が現在のユーザーにとって必須の更新かどうかなど、更新に関する重要な情報を返します。更新を利用できる場合は、Update または UpdateAsync を使用してインストールできます。後者のメソッドは、更新のインストールが完了すると UpdateCompleted イベントを発生させます。サイズの大きい更新の場合は、CheckForUpdateProgressChanged イベントと UpdateProgressChanged イベントによって進行状況の通知を受け取ることができます。また、ProgressChangedEventArgs の情報を使用して、ダウンロードのステータスをユーザーに通知することもできます。
ApplicationDeployment を使用すると、必要に応じてサイズの大きいファイルやアセンブリをダウンロードすることもできます。これらのファイルは、インストール時にダウンロードされないように、配置のアプリケーション マニフェスト内で "optional" としてマークする必要があります。DownloadFileGroup メソッドまたは DownloadFileGroupAsync メソッドを使用すると、アプリケーションの存続期間にいつでもファイルをダウンロードできます。AppDomain クラスの AssemblyResolve イベントのイベント ハンドラを提供することによって、アセンブリがメモリに読み込まれる前にダウンロードできます。詳細については、「チュートリアル : デザイナを使用し、ClickOnce 配置 API で必要に応じてアセンブリをダウンロードする」を参照してください。
![]() |
---|
ClickOnce アプリケーションの実行中にアプリケーションを更新した場合、Application の Restart メソッドを呼び出すまで、ユーザーは更新結果を確認できません。このメソッドは、アプリケーションの現在実行中のインスタンスを閉じ、すぐに再起動します。 |
ApplicationDeployment には、パブリック コンストラクタはありません。ClickOnce アプリケーション内のこのクラスのインスタンスは、CurrentDeployment プロパティを使用して取得します。現在のアプリケーションが ClickOnce アプリケーションかどうかを確認するには、IsNetworkDeployed プロパティを使用します。
ApplicationDeployment では、更新をチェックし、クラスのイベントとして完了コールバックを公開する新しい イベントベースの非同期パターンの概要 を使用して、最新のファイルを非同期でダウンロードできます。ApplicationDeployment は、スレッドを開始および管理し、適切な UI スレッドでアプリケーションをコールバックします。これにより、アプリケーションをロックせずに更新できるため、ユーザーは更新のインストール中も作業を続けることができます。更新の実行時にユーザーがすべての作業を中止する必要がある場合は、代わりに同期メソッドを使用することを検討してください。
![]() |
---|
非同期更新を実行するには、アプリケーションで System.Deployment 名前空間と System.ComponentModel 名前空間の両方をインポートする必要があります。 |

アプリケーションの読み込み時に、新しい更新を利用できるかどうかを確認し、必須の更新の場合は非同期でインストールするコード例を次に示します。
Private sizeOfUpdate As Long = 0 Dim WithEvents ADUpdateAsync As ApplicationDeployment Private Sub UpdateApplication() If (ApplicationDeployment.IsNetworkDeployed) Then ADUpdateAsync = ApplicationDeployment.CurrentDeployment ADUpdateAsync.CheckForUpdateAsync() End If End Sub Sub ADUpdateAsync_CheckForUpdateProgressChanged(ByVal sender As Object, ByVal e As DeploymentProgressChangedEventArgs) Handles ADUpdateAsync.CheckForUpdateProgressChanged DownloadStatus.Text = [String].Format("{0:D}K of {1:D}K downloaded.", e.BytesCompleted / 1024, e.BytesTotal / 1024) End Sub Sub ADUpdateAsync_CheckForUpdateCompleted(ByVal sender As Object, ByVal e As CheckForUpdateCompletedEventArgs) Handles ADUpdateAsync.CheckForUpdateCompleted If (e.Error IsNot Nothing) Then MessageBox.Show(("ERROR: Could not retrieve new version of the application. Reason: " + ControlChars.Lf + e.Error.Message + ControlChars.Lf + "Please report this error to the system administrator.")) Return Else If (e.Cancelled = True) Then MessageBox.Show("The update was cancelled.") End If End If ' Ask the user if they would like to update the application now. If (e.UpdateAvailable) Then sizeOfUpdate = e.UpdateSizeBytes If (Not e.IsUpdateRequired) Then Dim dr As DialogResult = MessageBox.Show("An update is available. Would you like to update the application now?", "Update Available", MessageBoxButtons.OKCancel) If (System.Windows.Forms.DialogResult.OK = dr) Then BeginUpdate() End If Else MessageBox.Show("A mandatory update is available for your application. We will install the update now, after which we will save all of your in-progress data and restart your application.") BeginUpdate() End If End If End Sub Private Sub BeginUpdate() ADUpdateAsync = ApplicationDeployment.CurrentDeployment ADUpdateAsync.UpdateAsync() End Sub Sub ADUpdateAsync_UpdateProgressChanged(ByVal sender As Object, ByVal e As DeploymentProgressChangedEventArgs) Handles ADUpdateAsync.UpdateProgressChanged Dim progressText As String = String.Format("{0:D}K out of {1:D}K downloaded - {2:D}% complete", e.BytesCompleted / 1024, e.BytesTotal / 1024, e.ProgressPercentage) DownloadStatus.Text = progressText End Sub Sub ADUpdateAsync_UpdateCompleted(ByVal sender As Object, ByVal e As AsyncCompletedEventArgs) Handles ADUpdateAsync.UpdateCompleted If (e.Cancelled) Then MessageBox.Show("The update of the application's latest version was cancelled.") Exit Sub Else If (e.Error IsNot Nothing) Then MessageBox.Show("ERROR: Could not install the latest version of the application. Reason: " + ControlChars.Lf + e.Error.Message + ControlChars.Lf + "Please report this error to the system administrator.") Exit Sub End If End If Dim dr As DialogResult = MessageBox.Show("The application has been updated. Restart? (If you do not restart now, the new version will not take effect until after you quit and launch the application again.)", "Restart Application", MessageBoxButtons.OKCancel) If (dr = System.Windows.Forms.DialogResult.OK) Then Application.Restart() End If End Sub
long sizeOfUpdate = 0; private void UpdateApplication() { if (ApplicationDeployment.IsNetworkDeployed) { ApplicationDeployment ad = ApplicationDeployment.CurrentDeployment; ad.CheckForUpdateCompleted += new CheckForUpdateCompletedEventHandler(ad_CheckForUpdateCompleted); ad.CheckForUpdateProgressChanged += new DeploymentProgressChangedEventHandler(ad_CheckForUpdateProgressChanged); ad.CheckForUpdateAsync(); } } void ad_CheckForUpdateProgressChanged(object sender, DeploymentProgressChangedEventArgs e) { downloadStatus.Text = String.Format("Downloading: {0}. {1:D}K of {2:D}K downloaded.", GetProgressString(e.State), e.BytesCompleted/1024, e.BytesTotal/1024); } string GetProgressString(DeploymentProgressState state) { if (state == DeploymentProgressState.DownloadingApplicationFiles) { return "application files"; } else if (state == DeploymentProgressState.DownloadingApplicationInformation) { return "application manifest"; } else { return "deployment manifest"; } } void ad_CheckForUpdateCompleted(object sender, CheckForUpdateCompletedEventArgs e) { if (e.Error != null) { MessageBox.Show("ERROR: Could not retrieve new version of the application. Reason: \n" + e.Error.Message + "\nPlease report this error to the system administrator."); return; } else if (e.Cancelled == true) { MessageBox.Show("The update was cancelled."); } // Ask the user if they would like to update the application now. if (e.UpdateAvailable) { sizeOfUpdate = e.UpdateSizeBytes; if (!e.IsUpdateRequired) { DialogResult dr = MessageBox.Show("An update is available. Would you like to update the application now?\n\nEstimated Download Time: ", "Update Available", MessageBoxButtons.OKCancel); if (DialogResult.OK == dr) { BeginUpdate(); } } else { MessageBox.Show("A mandatory update is available for your application. We will install the update now, after which we will save all of your in-progress data and restart your application."); BeginUpdate(); } } } private void BeginUpdate() { ApplicationDeployment ad = ApplicationDeployment.CurrentDeployment; ad.UpdateCompleted += new AsyncCompletedEventHandler(ad_UpdateCompleted); // Indicate progress in the application's status bar. ad.UpdateProgressChanged += new DeploymentProgressChangedEventHandler(ad_UpdateProgressChanged); } void ad_UpdateProgressChanged(object sender, DeploymentProgressChangedEventArgs e) { String progressText = String.Format("{0:D}K out of {1:D}K downloaded - {2:D}% complete", e.BytesCompleted / 1024, e.BytesTotal / 1024, e.ProgressPercentage); downloadStatus.Text = progressText; } void ad_UpdateCompleted(object sender, AsyncCompletedEventArgs e) { if (e.Cancelled) { MessageBox.Show("The update of the application's latest version was cancelled."); return; } else if (e.Error != null) { MessageBox.Show("ERROR: Could not install the latest version of the application. Reason: \n" + e.Error.Message + "\nPlease report this error to the system administrator."); return; } DialogResult dr = MessageBox.Show("The application has been updated. Restart? (If you do not restart now, the new version will not take effect until after you quit and launch the application again.)", "Restart Application", MessageBoxButtons.OKCancel); if (DialogResult.OK == dr) { Application.Restart(); } }
private: long sizeOfUpdate; private: void Form1_Load(Object^ sender, System::EventArgs^ e) { DoUpdate(); } public: void DoUpdate() { if (ApplicationDeployment::IsNetworkDeployed) { ApplicationDeployment^ currentAppDeployment = ApplicationDeployment::CurrentDeployment; currentAppDeployment->CheckForUpdateCompleted += gcnew CheckForUpdateCompletedEventHandler( this, &Form1::currentDeploy_CheckForUpdateCompleted); currentAppDeployment->CheckForUpdateAsync(); } } // If update is available, fetch it. void currentDeploy_CheckForUpdateCompleted(Object^ sender , CheckForUpdateCompletedEventArgs^ e) { if (nullptr != e->Error) { // Log error. return; } if (e->UpdateAvailable) { sizeOfUpdate = (long) e->UpdateSizeBytes; if (!e->IsUpdateRequired) { System::Windows::Forms::DialogResult updateDialogueResult = MessageBox::Show( "An update is available.Would you like to update the" + " application now?", "Update Available", MessageBoxButtons::OKCancel); if (System::Windows::Forms::DialogResult::OK == updateDialogueResult) { BeginUpdate(); } } else { BeginUpdate(); } } } void BeginUpdate() { ApplicationDeployment^ ad = ApplicationDeployment::CurrentDeployment; ad->UpdateCompleted += gcnew AsyncCompletedEventHandler( this, &Form1::CurrentDeployment_UpdateCompleted); // Indicate progress in the application's status bar. ad->UpdateProgressChanged += gcnew DeploymentProgressChangedEventHandler(this, &Form1::ad_ProgressChanged); ad->UpdateAsync(); } void CurrentDeployment_UpdateCompleted(Object^ sender, AsyncCompletedEventArgs^ e) { if (!e->Cancelled) { if (nullptr != e->Error) { System::Windows::Forms::DialogResult restartDialogueResult = MessageBox::Show( "The application has been updated. Restart?", "Restart Application", MessageBoxButtons::OKCancel); if (System::Windows::Forms::DialogResult::OK == restartDialogueResult) { Application::Restart(); } } else { // Replace with your own error reporting or logging. MessageBox::Show( "The application encountered an error in downloading" + " the latest update. Error: {0}", e->Error->Message); } } else { // Replace with your own error reporting or logging. MessageBox::Show("The update of the application's latest" + " version was cancelled."); } } void ad_ProgressChanged(Object^ sender, DeploymentProgressChangedEventArgs^ e) { String^ progressText = String::Format( "{0:D}K out of {1:D}K downloaded - {2:D}% complete", e->BytesCompleted / 1024, e->BytesTotal / 1024, e->ProgressPercentage); statusStrip1->Text = progressText; }

System.Deployment.Application.ApplicationDeployment


Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


ApplicationDeployment プロパティ

名前 | 説明 | |
---|---|---|
![]() | TimeOfLastUpdateCheck | ClickOnce がアプリケーションの更新を最後にチェックした日時を取得します。 |
![]() | UpdatedApplicationFullName | アプリケーションの更新後に、アプリケーションの完全名を取得します。 |
![]() | UpdatedVersion | 最近ダウンロードされた更新のバージョンを取得します。 |
![]() | UpdateLocation | このアプリケーションの更新元である Web サイトまたはファイル共有を取得します。 |

ApplicationDeployment メソッド


名前 | 説明 | |
---|---|---|
![]() | Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 ( Object から継承されます。) |
![]() | MemberwiseClone | 現在の Object の簡易コピーを作成します。 ( Object から継承されます。) |

ApplicationDeployment メンバ
プログラムによる現在の配置の更新と、必要に応じたファイルのダウンロードをサポートします。このクラスは継承できません。
ApplicationDeployment データ型で公開されるメンバを以下の表に示します。

名前 | 説明 | |
---|---|---|
![]() | TimeOfLastUpdateCheck | ClickOnce がアプリケーションの更新を最後にチェックした日時を取得します。 |
![]() | UpdatedApplicationFullName | アプリケーションの更新後に、アプリケーションの完全名を取得します。 |
![]() | UpdatedVersion | 最近ダウンロードされた更新のバージョンを取得します。 |
![]() | UpdateLocation | このアプリケーションの更新元である Web サイトまたはファイル共有を取得します。 |


名前 | 説明 | |
---|---|---|
![]() | Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 (Object から継承されます。) |
![]() | MemberwiseClone | 現在の Object の簡易コピーを作成します。 (Object から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | CheckForUpdateCompleted | CheckForUpdateAsync の完了時に発生します。 |
![]() | CheckForUpdateProgressChanged | CheckForUpdateAsync の呼び出しで進行状況の更新を使用できる場合に発生します。 |
![]() | DownloadFileGroupCompleted | ファイルのダウンロードが完了すると、メイン アプリケーション スレッドで発生します。 |
![]() | DownloadFileGroupProgressChanged | DownloadFileGroupAsync の呼び出しによって開始されたファイルのダウンロード操作で、ステータス情報を使用できる場合に発生します。 |
![]() | UpdateCompleted | UpdateAsync の呼び出しの結果として、ClickOnce がアプリケーションのアップグレードを完了したときに発生します。 |
![]() | UpdateProgressChanged | UpdateAsync の呼び出しによって開始された更新操作について、ClickOnce に新しいステータス情報がある場合に発生します。 |

Application deployment(デプロイメント)
出典: フリー百科事典『ウィキペディア(Wikipedia)』 (2020/07/18 06:33 UTC 版)
「Uniface」の記事における「Application deployment(デプロイメント)」の解説
Unifaceアプリケーションは、コードを変更することなく、携帯からメインフレームまでのプラットホームで展開(運用)することが可能。コンポーネント(スタートアップシェル、メニュー、ツールバーパネル、グリフ、グローバルPROC、インクルードPROC)は圧縮ファイルにパッケージ化され、全てのプラットホームに配布が可能なランタイムオブジェクトにコンパイルされる。ランタイムオブジェクトは、バーチュアルマシンとプラットホーム固有のインタプリタを使用し実行される。(後に、Javaと他の言語は、この方法でUnifaceに続いた) Uniface Virtual Machineが存在している環境なら、1台のマシンの上でコンポーネントをコンパイルして、別の環境で実行可能。
※この「Application deployment(デプロイメント)」の解説は、「Uniface」の解説の一部です。
「Application deployment(デプロイメント)」を含む「Uniface」の記事については、「Uniface」の概要を参照ください。
- application deploymentのページへのリンク