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) 方法,以便已注册的委托对事件进行接收。

适用于

另请参阅