System.Configuration.Install 命名空間

System.Configuration.Install 命名空間提供類別,可讓您寫入自己元件的自訂安裝程式。 The System.Configuration.Install namespace provides classes that allow you to write custom installers for your own components. Installer 類別是 .NET Framework 中所有自訂安裝程式的基底類別。 The Installer class is the base class for all custom installers in the .NET Framework.



載入組件,並且執行組件中的所有安裝程式。Loads an assembly, and runs all the installers in it.


指定安裝程式,其複製元件的屬性以使用於安裝期間。Specifies an installer that copies properties from a component to use at install time.


含有目前安裝的相關資訊。Contains information about the current installation.


提供自訂安裝的基礎。Provides the foundation for custom installations.


包含要在安裝期間執行的安裝程式集合。Contains a collection of installers to be run during an installation.


將資料提供給下列事件:BeforeInstallAfterInstallCommittingCommittedBeforeRollbackAfterRollbackBeforeUninstallAfterUninstallProvides data for the events: BeforeInstall, AfterInstall, Committing, Committed, BeforeRollback, AfterRollback, BeforeUninstall, AfterUninstall.


安裝的認可、復原或解除安裝階段發生錯誤時所擲回的例外狀況。The exception that is thrown when an error occurs during the commit, rollback, or uninstall phase of an installation.


表示 Managed 安裝。Represents a managed install.


定義完全成功或失敗的安裝程式,並且保留電腦在初始狀態。Defines an installer that either succeeds completely or fails and leaves the computer in its initial state.



提供受管理之安裝程式的介面。Provides an interface for a managed installer.



指定解除安裝期間安裝程式應該執行的動作。Specifies what an installer should do during an uninstallation.



表示處理 BeforeInstallAfterInstallCommittingCommittedBeforeRollbackAfterRollbackBeforeUninstallAfterUninstallInstaller 事件的方法。Represents the method that will handle the BeforeInstall, AfterInstall, Committing, Committed, BeforeRollback, AfterRollback, BeforeUninstall, or AfterUninstall event of an Installer.


透過Installers 屬性中,安裝程式包含其他的安裝程式,做為子系的集合。Through the Installers property, an installer contains a collection of other installers as children. 當執行安裝程式時,它會不斷循環及其子系和呼叫InstallCommitRollback,或UninstallAs the installer is executed, it cycles through its children and calls Install, Commit, Rollback, or Uninstall. 如需範例中的物件Installers集合,請參閱EventLogInstallerFor an example of an object in the Installers collection, see EventLogInstaller.

Context屬性包含安裝的相關資訊。The Context property contains information about the installation. 例如,安裝時,會將所需的資訊儲存檔案的位置的記錄檔的位置相關的資訊Uninstall方法,並安裝可執行檔執行時所輸入的命令列。For example, information about the location of the log file for the installation, the location of the file that saves information required by the Uninstall method, and the command line that was entered when the installation executable was run. 如需安裝可執行檔的範例,請參閱 < Installutil.exe (安裝程式工具)For an example of an installation executable, see Installutil.exe (Installer Tool).

InstallCommitRollback,以及Uninstall方法都不一定會呼叫同一個執行個體上InstallerThe Install, Commit, Rollback, and Uninstall methods are not always called on the same instance of Installer. 例如,您可以使用Installer安裝並認可應用程式,然後釋放的參考InstallerFor example, you might use an Installer to install and commit an application, and then release the reference to that Installer. 更新版本中,解除安裝應用程式會建立新的參考Installer,這表示Uninstall另一個執行個體上呼叫方法InstallerLater, uninstalling the application creates a new reference to an Installer, which means that the Uninstall method is called on a different instance of Installer. 基於這個理由,安裝程式中儲存電腦的狀態。For this reason, do not save the state of a computer in an installer. 請改用IDictionary,會保留在呼叫之間,並傳入InstallCommitRollback,和Uninstall方法。Instead, use an IDictionary that is preserved across calls and passed into the Install, Commit, Rollback, and Uninstall methods.