Installer.Install(IDictionary) Installer.Install(IDictionary) Installer.Install(IDictionary) Installer.Install(IDictionary) Method

定义

在派生类中被重写时,执行安装。When overridden in a derived class, performs the installation.

public:
 virtual void Install(System::Collections::IDictionary ^ stateSaver);
public virtual void Install (System.Collections.IDictionary stateSaver);
abstract member Install : System.Collections.IDictionary -> unit
override this.Install : System.Collections.IDictionary -> unit
Public Overridable Sub Install (stateSaver As IDictionary)

参数

stateSaver
IDictionary IDictionary IDictionary IDictionary

IDictionary,它用于保存执行提交、回滚或卸载操作所需的信息。An IDictionary used to save information needed to perform a commit, rollback, or uninstall operation.

异常

stateSaver 参数为 nullThe stateSaver parameter is null.

该集合的一个安装程序的 BeforeInstall 事件处理程序发生异常。An exception occurred in the BeforeInstall event handler of one of the installers in the collection.

-or- 该集合的一个安装程序的 AfterInstall 事件处理程序发生异常。An exception occurred in the AfterInstall event handler of one of the installers in the collection.

示例

下面的示例演示InstallInstaller类的方法。The following example demonstrates the Install method of the Installer class. 类派生自Installer基类Install , 方法被重写。A class is derived from the Installer base class and the Install method is overridden.

   // Override the 'Install' method of the Installer class.
public:
   virtual void Install( IDictionary^ mySavedState ) override
   {
      Installer::Install( mySavedState );
      // Code maybe written for installation of an application.
      Console::WriteLine( "The Install method of 'MyInstallerSample' has been called" );
   }
// Override the 'Install' method of the Installer class.
public override void Install( IDictionary mySavedState )
{
   base.Install( mySavedState );
   // Code maybe written for installation of an application.
   Console.WriteLine( "The Install method of 'MyInstallerSample' has been called" );
}
' Override the 'Install' method of the Installer class.
Public Overrides Sub Install(mySavedState As IDictionary)
   MyBase.Install(mySavedState)
   ' Code maybe written for installation of an application.
   Console.WriteLine("The Install method of 'MyInstallerSample' has been called")
End Sub

继承者说明

-如果在派生类Install(IDictionary)中重写方法, 请确保先在派生方法中调用基类Install(IDictionary)的方法。- If you override the Install(IDictionary) method in a derived class, be sure to call the base class's Install(IDictionary) method first in your derived method. 方法调用此实例的Installers属性中包含的每个安装程序的方法。Install(IDictionary) Install(IDictionary)The Install(IDictionary) method calls the Install(IDictionary) method of each installer contained in the Installers property of this instance. 在包含的安装程序运行后, 此方法IDictionary更新对象 ( stateSaver通过参数指定) 以反映安装的状态。After the contained installers run, this method updates the IDictionary object (specified through the stateSaver parameter) to reflect the status of the installation. IDictionary 传递Install(IDictionary)给方法时, 应为空。The IDictionary should be empty when passed to the Install(IDictionary) method. 如果所有Install(IDictionary)方法均成功Commit(IDictionary) , 则调用方法。If all the Install(IDictionary) methods succeed, the Commit(IDictionary) method is called. 否则, Rollback(IDictionary)将调用方法。Otherwise, the Rollback(IDictionary) method is called.

-如果需要将安装程序实例添加到Installers Install(IDictionary)方法中的集合, 请确保在Uninstall(IDictionary)方法中对集合执行相同的添加。- If you need to add installer instances to the Installers collection in the Install(IDictionary) method, be sure to perform the same additions to the collection in the Uninstall(IDictionary) method. 但是, 如果将安装程序实例添加到自定义安装程序的类构造函数中Installers的集合, 则可以避免在这两种方法中维护该集合。However, you can avoid maintaining the collection in both methods if you add installer instances to the Installers collection in the class constructor for your custom installer.

适用于

另请参阅