2010-05-04 16 views
9

Cuando comienzo a la instalación utilizando installutil me da error de seguimiento, yo he puesto ServiceInstaller y ServiceInstallerProcessservicio de Windows Problema de instalación

System.InvalidOperationException: La instalación falló debido a la ausencia de un ServiceProcessInstaller. ServiceProcessInstaller debe ser el instalador contenedor o debe estar presente en la colección Installers en el mismo instalador que ServiceInstaller.

Esperando sus valiosos pensamientos.

Agradeciendo

Respuesta

1

Por lo general, esto significa que usted no pudo atribuir a su instalador con RunInstaller (verdadero). Aquí está un ejemplo de una práctica que tengo funciona:

namespace OnpointConnect.WindowsService 
{ 
    [RunInstaller(true)] 
    public partial class OnpointConnectServiceInstaller : Installer 
    { 
     private ServiceProcessInstaller processInstaller; 
     private ServiceInstaller serviceInstaller; 

     public OnpointConnectServiceInstaller() 
     { 
      InitializeComponent(); 
     } 

     public override string HelpText 
     { 
      get 
      { 
       return 
        "/name=[service name]\nThe name to give the OnpointConnect Service. " + 
        "The default is OnpointConnect. Note that each instance of the service should be installed from a unique directory with its own config file and database."; 
      } 
     } 

     public override void Install(IDictionary stateSaver) 
     { 
      Initialize(); 
      base.Install(stateSaver); 
     } 

     public override void Uninstall(IDictionary stateSaver) 
     { 
      Initialize(); 
      base.Uninstall(stateSaver); 
     } 

     private void Initialize() 
     { 
      processInstaller = new ServiceProcessInstaller(); 
      serviceInstaller = new ServiceInstaller(); 
      processInstaller.Account = ServiceAccount.LocalSystem; 
      serviceInstaller.StartType = ServiceStartMode.Manual; 

      string serviceName = "OnpointConnect"; 
      if (Context.Parameters["name"] != null) 
      { 
       serviceName = Context.Parameters["name"]; 
      } 
      Context.LogMessage("The service name = " + serviceName); 

      serviceInstaller.ServiceName = serviceName; 

      try 
      { 
       //stash the service name in a file for later use in the service 
       var writer = new StreamWriter("ServiceName.dat"); 
       try 
       { 
        writer.WriteLine(serviceName); 
       } 
       finally 
       { 
        writer.Close(); 
       } 

       Installers.Add(serviceInstaller); 
       Installers.Add(processInstaller); 
      } 
      catch (Exception err) 
      { 
       Context.LogMessage("An error occured while creating configuration information for the service. The error is " 
            + err.Message); 
      } 
     } 
    } 
} 
20

tuve el mismo problema con el instalador y encontraron que en los .Designer.cs [YourInstallerClassName] en InitializeComponent() método, el DFAULT código generado es que falta añadir el ServiceProcessInstaller

 // 
     // [YourInstallerClassName] 
     // 
     this.Installers.AddRange(new System.Configuration.Install.Installer[] { 
     this.serviceInstaller1}); 

Sólo tiene que añadir su ServiceProcessInstaller en mi caso su:

 // 
     // ProjectInstaller 
     // 
     this.Installers.AddRange(new System.Configuration.Install.Installer[] { 
     this.serviceProcessInstaller1, //--> Missing 
     this.serviceInstaller1}); 

y trabaja el proyecto de instalación.

+0

+1, gracias. ¿Conoces alguna forma de hacer lo mismo a través de UI? – FMFF

+1

@FMFF, para cualquiera que esté interesado en hacerlo a través de la interfaz de usuario, solo asegúrese de que tanto serviceInstaller como serviceProcessInstallers en su proyecto de instalación tengan el elemento primario como ProjectInstaller. – shadowf

+0

gracias, se solucionó mi problema de instalación. – yadavr

Cuestiones relacionadas