TransactedInstaller与嵌套安装程序

时间:2009-03-28 15:48:54

标签: c# installer service-installer

这个(嵌套安装程序)

之间有区别吗?
ServiceInstaller si = new ServiceInstaller();
si.ServiceName = "MyService";

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

spi.Installers.Add(si);

this.Installers.Add(spi);  

这个? (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);   

默认情况下是否嵌套安装程序?应该选择哪种风格?

1 个答案:

答案 0 :(得分:5)

如果自定义操作成功/失败,

TransactedInstaller 将自动调用Commit / Rollback。

使用 嵌套安装程序 ,您将需要在发生错误的情况下对回滚/提交您自己进行排序,如果您没有明确说明,则不会调用它们他们跑。