EventLogInstaller.Install(IDictionary) 方法

定義

執行安裝,並將事件記錄檔資訊寫入至登錄。Performs the installation and writes event log information to the registry.

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

參數

stateSaver
IDictionary

IDictionary,用來儲存執行復原或解除安裝作業所需的資訊。An IDictionary used to save information needed to perform a rollback or uninstall operation.

例外狀況

Source 屬性中指定的名稱是已經為不同事件記錄檔註冊的名稱。The name specified in the Source property is already registered for a different event log.

備註

方法Install會將事件記錄檔資訊寫入登錄, 並將事件記錄檔與Log屬性所指定的記錄檔產生關聯。The Install method writes event log information to the registry, and associates the event log with a log that is specified by the Log property. 如果記錄檔不存在 (而且已指定來源), Install則會建立記錄檔, 並將新的來源與它產生關聯。If the log does not already exist (and a source is specified), Install creates a log and associates the new source with it.

一般來說, 您不會EventLogInstaller從程式碼中呼叫的方法, 它們通常只會由installutil.exe (安裝程式工具)所呼叫。Typically, you do not call the methods of the EventLogInstaller from within your code; they are generally called only by the Installutil.exe (Installer Tool). 此工具會在安裝Install過程中自動呼叫方法, 以寫入與所安裝事件記錄檔相關聯的登錄資訊。The tool automatically calls the Install method during the installation process to write registry information that is associated with the event log being installed. 安裝是交易式的, 因此, 如果安裝期間發生任何安裝專案元件失敗, 所有先前安裝的元件都會復原到其安裝前狀態。Installation is transactional, so if there is a failure of any installation project component during the installation, all the previously-installed components are rolled back to their pre-installation states. 這是藉由呼叫每個元件Rollback的方法來完成。This is accomplished by calling each component's Rollback method.

使用EventLogInstaller為新的或現有的事件記錄檔註冊新的來源, 請勿使用EventLogInstaller來變更現有的來源。Use EventLogInstaller to register a new source for a new or existing event log; do not use EventLogInstaller to change an existing source. EventLogInstaller類別不會修改現有來源的設定屬性, 以符合指定的安裝內容。The EventLogInstaller class does not modify the configuration properties of an existing source to match the specified installation properties. 如果屬性符合針對電腦上的不同事件記錄檔註冊的來源名稱,方法會擲回例外狀況。Install SourceThe Install method throws an exception if the Source property matches a source name that is registered for a different event log on the computer. 如果屬性符合已為Install Log屬性中指定的相同事件記錄檔註冊的來源名稱, 則方法會略過註冊來源。 SourceThe Install method skips registering the source if the Source property matches a source name that is already registered for the same event log specified in the Log property.

應用程式的安裝常式會使用專案安裝程式Installer.Context的屬性, 自動維護已安裝之元件的相關資訊。An application's install routine uses the project installer's Installer.Context property to automatically maintain information about the components that have already been installed. 此狀態資訊 (當做Install stateSaver參數傳遞至) 會在工具安裝每個EventLogInstaller時持續更新。This state information, which is passed to Install as the stateSaver parameter, is continuously updated as the tool installs each EventLogInstaller. 通常, 您的程式碼不需要明確地修改此狀態資訊。Usually, it is not necessary for your code to explicitly modify this state information.

適用於

另請參閱