Help‎ > ‎NvnInstaller.MsiDotNet‎ > ‎

Installer-Classes

.Net application needs to subscribe InstallerMessageReceived event to handle Windows Installer messages. InstallerMessage object can be typecasted to specific InstallerMessage classes to obtain detailed information
 
ResetMessage
        Ticks - Total number of ticks in the progress bar.
        Direction - Progress bar motion direction.
        IsApproximate - The estimate of the total number of ticks is an approximation and may be inaccurate.

ProgressReportMessage
        TicksMoved - Number of ticks the progress bar has moved.
  
ActionStartMessage
        Time - Time when the action was started
        Action - Action name in MSI database sequence table
        Description - Description of the current action started by windows installer

ActionDataMessage
        Message - Formatted message received from Windows Installer describing current action.

InformationMessage
        Message - Formatted user/log message

InstallCompleteMessage
        Success - Specifies whether installation is successful or not

FileInUseMessage
        FilePath - Location of the file which is supposed to be removed by uninstallation or overwritten by new installation

ErrorMessage
        Message - Formatted error message received from Windows Installer
        ErrorMessageType - Specifies whether message is FatalExit, Error or Warning
  
Following code shows how to use InstallerMessageReceived event
  
    void msiInstaller_InstallerMessageReceived(object sender, InstallerMessageEventArgs e) {
      if (e.InstallerMessage.Type == InstallerMessageType.ProgressReport) {
        if (reset) {
          ProgressReportMessage progressReportMessage = (ProgressReportMessage)e.InstallerMessage;
          if (approximate && installPrograssBar.Maximum < (installPrograssBar.Value + progressReportMessage.TicksMoved)) return;
          installPrograssBar.Value += (int)progressReportMessage.TicksMoved;
        }
      } else if (e.InstallerMessage.Type == InstallerMessageType.ResetMessage) {
        reset = false;

        // set progress bar properties
        ResetMessage resetMessage = (ResetMessage)e.InstallerMessage;
        installPrograssBar.Maximum = (int)resetMessage.Ticks;
        installPrograssBar.Minimum = 0;
        installPrograssBar.Step = 1;
        installPrograssBar.Value = 0;

        approximate = resetMessage.IsApproximate;
        reset = true;
      } else if (e.InstallerMessage.Type == InstallerMessageType.ActionData) {
        SetLabel(((ActionDataMessage)e.InstallerMessage).Message);
      } else if (e.InstallerMessage.Type == InstallerMessageType.ActionStart) {
        ActionStartMessage actionStartMessage = (ActionStartMessage)e.InstallerMessage;
        SetLabel(actionStartMessage.Action + ": " + actionStartMessage.Description);
      } else if (e.InstallerMessage.Type == InstallerMessageType.FileInUse) {
        MsiResponse userAction = (MsiResponse)MessageBox.Show("file in use:" + ((FileInUseMessage)e.InstallerMessage).FilePath, "File in use", MessageBoxButtons.AbortRetryIgnore);
        msiInstaller.SetUserAction(userAction);
      } else if (e.InstallerMessage.Type == InstallerMessageType.InstallationComplete) {
        SetLabel("Installation Completed");
      }

      // Cancel installation
      if (cancel && e.SetUserAction) {
        msiInstaller.SetUserAction(MsiResponse.Cancel);
      }
    }