
如上图示,在安装程序上有多个Windows服务,将serviceInstaller2、serviceInstaller3删除后再添加,编译、安装,你会发现再也没办法成功安装这两个服务了,后来将前后的文件进行比较,发现问题主要在ProjectInstaller.Designer.cs上,下边列出了修改前后的代码,注意红色部分。
修改前:
private void InitializeComponent()
{
this.serviceProcessInstaller1 = new System.ServiceProcess.ServiceProcessInstaller();
this.serviceInstaller1 = new System.ServiceProcess.ServiceInstaller();
this.serviceInstaller2 = new System.ServiceProcess.ServiceInstaller();
this.serviceInstaller3 = new System.ServiceProcess.ServiceInstaller();
//
// serviceProcessInstaller1
//
this.serviceProcessInstaller1.Account = System.ServiceProcess.ServiceAccount.LocalSystem;
this.serviceProcessInstaller1.Password = null;
this.serviceProcessInstaller1.Username = null;
//
// serviceInstaller1
//
this.serviceInstaller1.ServiceName = "Service1";
this.serviceInstaller1.StartType = System.ServiceProcess.ServiceStartMode.Automatic;
//
// serviceInstaller2
//
this.serviceInstaller2.ServiceName = "Service2";
this.serviceInstaller2.StartType = System.ServiceProcess.ServiceStartMode.Automatic;
//
// serviceInstaller3
//
this.serviceInstaller3.ServiceName = "Service3";
this.serviceInstaller3.StartType = System.ServiceProcess.ServiceStartMode.Automatic;
//
// ProjectInstaller
//
this.Installers.AddRange(new System.Configuration.Install.Installer[] {
this.serviceProcessInstaller1,
this.serviceInstaller1,
[color=Red]this.serviceInstaller2,
this.serviceInstaller3[/color]});
}修改后:
private void InitializeComponent()
{
this.serviceProcessInstaller1 = new System.ServiceProcess.ServiceProcessInstaller();
this.serviceInstaller1 = new System.ServiceProcess.ServiceInstaller();
this.serviceInstaller2 = new System.ServiceProcess.ServiceInstaller();
this.serviceInstaller3 = new System.ServiceProcess.ServiceInstaller();
//
// serviceProcessInstaller1
//
this.serviceProcessInstaller1.Account = System.ServiceProcess.ServiceAccount.LocalSystem;
this.serviceProcessInstaller1.Password = null;
this.serviceProcessInstaller1.Username = null;
//
// serviceInstaller1
//
this.serviceInstaller1.ServiceName = "Service1";
this.serviceInstaller1.StartType = System.ServiceProcess.ServiceStartMode.Automatic;
//
// serviceInstaller2
//
this.serviceInstaller2.ServiceName = "Service2";
this.serviceInstaller2.StartType = System.ServiceProcess.ServiceStartMode.Automatic;
//
// serviceInstaller3
//
this.serviceInstaller3.ServiceName = "Service3";
this.serviceInstaller3.StartType = System.ServiceProcess.ServiceStartMode.Automatic;
//
// ProjectInstaller
//
this.Installers.AddRange(new System.Configuration.Install.Installer[] {
this.serviceProcessInstaller1,
this.serviceInstaller1});
}
评论(0)
暂无评论。