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

備註

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

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

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

給繼承者的注意事項

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

適用於

另請參閱