一个程序集中的多个服务.安装程序如何知道要安装和启动哪个服务
本文关键字:安装 程序 服务 何知道 启动 一个 程序集 集中 | 更新日期: 2023-09-27 17:56:51
我有一个包含2个Windows服务的项目。我创建了一个项目安装程序来安装这些项目,它工作正常。但我有一个问题;给定下面定义的代码,项目安装程序如何知道要为 serviceInstaller1 安装哪个服务,为服务安装程序 2 安装哪个服务?
它是否仅基于服务名称?
[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);
}
}
}
它基于 ServiceName
。
安装程序并不真正关心名称,您可以提供几乎任何名称,安装程序将很乐意为您注册具有此名称的 Windows 服务,但是当您尝试启动服务时,它将失败,除非它在您的程序集中找到与安装程序中指定的ServiceName
ServiceName
匹配的服务。
Error 1083: The executable program that this service is configured to run in does not implement the service.