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.

範例

下列範例示範Install Installer類別的方法。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.

適用於

另請參閱