3

Is there an difference between this (nested Installer)

ServiceInstaller si = new ServiceInstaller();
si.ServiceName = "MyService";

ServiceProcessInstaller spi = new ServiceProcessInstaller();
spi.Account = ServiceAccount.LocalSystem;

spi.Installers.Add(si);

this.Installers.Add(spi);  

and this? (TransactedInstaller)

TransactedInstaller ti = new TransactedInstaller();

ServiceInstaller si = new ServiceInstaller();
si.ServiceName = "MyService";
ti.Installers.Add(si);

ServiceProcessInstaller spi = new ServiceProcessInstaller();
spi.Account = ServiceAccount.LocalSystem;
ti.Installers.Add(spi);

this.Installers.Add(ti);   

Are nested Installer by default transacted? Which style should be prefered?

Michael Piendl
  • 2,864
  • 1
  • 27
  • 21

1 Answers1

5

TransactedInstaller will call Commit/Rollback automaticly if the custom action has succeeded/failed.

With nested installer you will need to sequence the Rollback/Commit your self in a case of an error, they will not be called if you didn't explicitly tell them to run.

Shay Erlichmen
  • 31,691
  • 7
  • 68
  • 87