Several services in one assembly. How does the installer know which service to install and run?

I have a project that includes 2 service windows. I am creating a ProjectInstaller to install these elements that works great. But I have a question; Based on the code below, how does the project installer know which service to install for serviceInstaller1 and which for serviceInstaller2?

Is it just based on ServiceName?

[RunInstaller(true)] public partial class ProjectInstaller : System.Configuration.Install.Installer { private ServiceProcessInstaller process; private ServiceInstaller serviceInstaller1; private ServiceInstaller serviceInstaller2; public ProjectInstaller() { InitializeComponent(); try { process = new ServiceProcessInstaller(); process.Account = ServiceAccount.LocalSystem; serviceInstaller1 = new ServiceInstaller(); serviceInstaller1.ServiceName = "xxx"; serviceInstaller1.Description = "Does Something"; serviceInstaller1.StartType = ServiceStartMode.Automatic; serviceInstaller2 = new ServiceInstaller(); serviceInstaller2.ServiceName = "yyy"; serviceInstaller2.Description = "Does something else"; serviceInstaller2.StartType = ServiceStartMode.Automatic; Installers.Add(process); Installers.Add(serviceInstaller1); Installers.Add(serviceInstaller2); } catch (Exception ex) { throw new Exception("Failed", ex); } } } 
+4
source share
1 answer

It is based on ServiceName .

The installer really does not care about the name, you can provide almost any name, and the installer will be happy to register a Windows service with this name for you, but when you try to start the service, it will fail if it does not find a service in your assembly that has ServiceName . corresponding to the ServiceName specified in the installer.

 Error 1083: The executable program that this service is configured to run in does not implement the service. 
+4
source

All Articles