/// <summary> /// Executes a built-in action, custom action, or user-interface wizard action. /// </summary> /// <param name="action">Name of the action to execute. Case-sensitive.</param> /// <param name="actionData">Optional data to be passed to a deferred custom action.</param> /// <exception cref="InvalidHandleException">the Session handle is invalid</exception> /// <exception cref="InstallCanceledException">the user exited the installation</exception> /// <remarks><p> /// The DoAction method executes the action that corresponds to the name supplied. If the /// name is not recognized by the installer as a built-in action or as a custom action in /// the CustomAction table, the name is passed to the user-interface handler object, which /// can invoke a function or a dialog box. If a null action name is supplied, the installer /// uses the upper-case value of the ACTION property as the action to perform. If no property /// value is defined, the default action is performed, defined as "INSTALL". /// </p><p> /// Actions that update the system, such as the InstallFiles and WriteRegistryValues /// actions, cannot be run by calling MsiDoAction. The exception to this rule is if DoAction /// is called from a custom action that is scheduled in the InstallExecuteSequence table /// between the InstallInitialize and InstallFinalize actions. Actions that do not update the /// system, such as AppSearch or CostInitialize, can be called. /// </p><p> /// If the called action is a deferred, rollback, or commit custom action, then the supplied /// <paramref name="actionData"/> will be available via the <see cref="CustomActionData"/> /// property of that custom action's session. /// </p><p> /// Win32 MSI API: /// <a href="http://msdn.microsoft.com/library/en-us/msi/setup/msidoaction.asp">MsiDoAction</a> /// </p></remarks> public void DoAction(string action, CustomActionData actionData) { if (string.IsNullOrWhiteSpace(action)) { throw new ArgumentNullException("action"); } this.ValidateSessionAccess(); if (actionData != null) { this[action] = actionData.ToString(); } uint ret = RemotableNativeMethods.MsiDoAction((int)this.Handle, action); if (ret != 0) { throw InstallerException.ExceptionFromReturnCode(ret); } }