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.


表示托管安装。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. 在执行安装程序时,它会循环调试其子级,并调用 InstallCommitRollbackUninstallAs 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).

Install、、 Commit RollbackUninstall 方法并非始终在的同一实例上调用 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 跨调用保留并传入 InstallCommitRollbackUninstall 方法的。Instead, use an IDictionary that is preserved across calls and passed into the Install, Commit, Rollback, and Uninstall methods.