Installer.OnBeforeInstall(IDictionary) 方法

定義

引發 BeforeInstall 事件。

protected:
 virtual void OnBeforeInstall(System::Collections::IDictionary ^ savedState);
protected virtual void OnBeforeInstall (System.Collections.IDictionary savedState);
abstract member OnBeforeInstall : System.Collections.IDictionary -> unit
override this.OnBeforeInstall : System.Collections.IDictionary -> unit
Protected Overridable Sub OnBeforeInstall (savedState As IDictionary)

參數

savedState
IDictionary

IDictionary,包含 Installers 屬性中的安裝程式安裝之前的電腦狀態。 這個 IDictionary 物件此時應該是空白的。

範例

下列範例示範 OnBeforeInstall 方法。 這個方法會在衍生類別中覆寫。 提供空格以新增在 方法中 OnBeforeInstall 安裝之前要完成的步驟。

   // Override the 'OnBeforeInstall' method.
protected:
   virtual void OnBeforeInstall( IDictionary^ savedState ) override
   {
      Installer::OnBeforeInstall( savedState );
      
      // Add steps to be done before the installation starts.
      Console::WriteLine( "OnBeforeInstall method of MyInstaller called" );
   }
// Override the 'OnBeforeInstall' method.
protected override void OnBeforeInstall(IDictionary savedState)
{
   base.OnBeforeInstall(savedState);
   // Add steps to be done before the installation starts.
   Console.WriteLine("OnBeforeInstall method of MyInstaller called");
}
' Override the 'OnBeforeInstall' method.
Protected Overrides Sub OnBeforeInstall(savedState As IDictionary)
   MyBase.OnBeforeInstall(savedState)
   ' Add steps to be done before the installation starts.
   Console.WriteLine("OnBeforeInstall method of MyInstaller called")
End Sub

備註

呼叫這個方法之前 Install 會呼叫這個實例 InstallerCollection 中安裝程式的方法。

引發事件會透過委派叫用此事件處理常式。 如需詳細資訊,請參閱 處理和引發事件

方法 OnBeforeInstall 可讓衍生類別處理事件,而不附加委派。 這是在衍生類別中處理事件的慣用技巧。

給繼承者的注意事項

當在衍生類別中覆寫 OnBeforeInstall(IDictionary) 時,請確定呼叫基底類別的 OnBeforeInstall(IDictionary) 方法,使已註冊的委派能接收到事件。

適用於

另請參閱