木子屋 Dnawo's BLOG

VS2008 Windows服务在安装程序上删除再添加无法安装

👤 dnawo 📅 2009-03-20 👁 5964 👍 0 💬 0 🔄 本站原创
图片

如上图示,在安装程序上有多个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)

暂无评论。

计算题
评论需审核通过后显示
← 上一篇 在FF和Opera下避免用elementNode.getAttr… 下一篇 → 博士后和工人解决同一个问题的方法,值得思考