3
私はServiceProcessInstallerに2つのServiceInstallerを追加しました。その後、私は以下のように私のメインを()に変更haved:まだそれは私のサービス1を実行している複数のServiceInstallerがWindowsサービスの1つのServiceProcessInstallerにあります
private void InitializeComponent()
{
this.Service1ProcessInstaller = new System.ServiceProcess.ServiceProcessInstaller();
this.Service1Installer = new System.ServiceProcess.ServiceInstaller();
this.Service2Installer = new System.ServiceProcess.ServiceInstaller();
//
// Service1ProcessInstaller
//
this.Service1ProcessInstaller.Account = System.ServiceProcess.ServiceAccount.LocalSystem;
this.Service1ProcessInstaller.Password = null;
this.Service1ProcessInstaller.Username = null;
//
// Service1Installer
//
this.Service1Installer.ServiceName = "Service1";
this.Service1Installer.ServicesDependedOn = new string[] {"Service2"};
//
// Service2Installer
//
this.Service2Installer.ServiceName = "Service2";
//
// ProjectInstaller
//
this.Installers.AddRange(new System.Configuration.Install.Installer[] {
this.Service1ProcessInstaller,
this.Service1Installer,
this.Service2Installer});
}
:
私も以下のようにサービス1に依存してサービスとしてサービス2を設定しているstatic void Main()
{
ServiceBase[] ServicesToRun;
ServicesToRun = new ServiceBase[]
{
new Service1(),
new Service2()
};
ServiceBase.Run(ServicesToRun);
}
。
Service2は決して呼び出しません。
Main()のシーケンスを変更した場合、Service2は呼び出すだけです。
常に最初のサービスを呼び出しています。
私の両方のサービスに電話するには?
'services.msc'を開くと、そこに2つのサービスがありますか? – zaitsman
@zaitsmanいいえ、私は持っていません。それはmyService.exe –