2010-05-04 32 views
9

Kiedy zacznę instalacji przy użyciu installutil daje mi następujący błąd, mam ustawione ServiceInstaller i ServiceInstallerProcessusługi Windows Problem Instalacja

System.InvalidOperationException: Instalacja nie powiodła się z powodu braku ServiceProcessInstaller. ServiceProcessInstaller musi być instalatorem zawierającym lub musi być obecny w kolekcji Installers na tym samym instalatorze co ServiceInstaller.

Czekam na twoje cenne myśli.

Dziękując

Odpowiedz

1

Zazwyczaj oznacza to, że nie udało się przypisać instalatora z RunInstaller (true). Oto przykład jednego mam pod ręką, że działa:

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

miałem ten sam problem z instalatora i stwierdził, że w [YourInstallerClassName] .Designer.cs w InitializeComponent() metody, dfault Wygenerowany kod jest Brakujące dodaj ServiceProcessInstaller

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

Wystarczy dodać ServiceProcessInstaller w moim przypadku ITS:

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

i działa projekt instalacyjny.

+0

+1, dziękuję. Czy znasz jakiś sposób, aby zrobić to samo za pomocą interfejsu użytkownika? – FMFF

+1

@FMFF, dla wszystkich zainteresowanych robi to za pośrednictwem interfejsu użytkownika, wystarczy upewnić się, że zarówno serviceInstaller, jak i serviceProcessInstallers w projekcie instalatora mają element nadrzędny jako ProjectInstaller. – shadowf

+0

thanx, rozwiązał mój problem z instalacją. – yadavr