Installer.OnBeforeInstall(IDictionary) 方法

定義

引發 BeforeInstall 事件。Raises the BeforeInstall event.

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 屬性中的安裝程式安裝之前的電腦狀態。An IDictionary that contains the state of the computer before the installers in the Installers property are installed. 這個時候 IDictionary 物件應該是空的。This IDictionary object should be empty at this point.

範例

下列範例示範OnBeforeInstall方法。The following example demonstrates the OnBeforeInstall method. 這個方法會在衍生類別中覆寫。This method is overridden in the derived class. 提供空間, 以在OnBeforeInstall方法中安裝之前新增要執行的步驟。Space is provided to add steps to be done before the installation in the OnBeforeInstall method.

   // 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實例中安裝程式的方法之前呼叫。This method is called before the Install methods of the installers in this instance's InstallerCollection are called.

引發事件會透過委派叫用此事件處理常式。Raising an event invokes the event handler through a delegate. 如需詳細資訊, 請參閱處理和引發事件For more information, see Handling and Raising Events.

OnBeforeInstall方法可讓衍生類別處理事件, 而不需要附加委派。The OnBeforeInstall method allows derived classes to handle the event without attaching a delegate. 這是在衍生類別中處理事件的慣用技巧。This is the preferred technique for handling the event in a derived class.

給繼承者的注意事項

當在衍生類別中覆寫 OnBeforeInstall(IDictionary) 時,請確定呼叫基底類別的 OnBeforeInstall(IDictionary) 方法,使已註冊的委派能接收到事件。When overriding OnBeforeInstall(IDictionary) in a derived class, be sure to call the base class's OnBeforeInstall(IDictionary) method so that registered delegates receive the event.

適用於

另請參閱