1 台のマシンに同じサービスを複数回インストールできるようにする必要があります。私が働いているその部分!しかし、ServiceName も異なる必要があります。その部分はそうではありません。
以下は、Installer.cs 内のコードです。
[RunInstaller(true)]
public partial class ProjectInstaller : System.Configuration.Install.Installer
{
public ProjectInstaller()
{
InitializeComponent();
}
public override void Install(IDictionary stateSaver)
{
RetrieveServiceName();
base.Install(stateSaver);
}
public override void Uninstall(IDictionary savedState)
{
RetrieveServiceName();
base.Uninstall(savedState);
}
private void RetrieveServiceName()
{
var serviceName = Context.Parameters["servicename"];
if(!string.IsNullOrEmpty(serviceName))
{
auditStreamServiceInstaller.ServiceName = serviceName;
auditStreamServiceInstaller.DisplayName = serviceName;
}
}
}
次のコマンドを使用してサービスをインストールします
C:\Windows\Microsoft.Net\Framework\v4.0.30319> installutil /servicename="AuditStream-NW" d:AuditStreamService.exe
installlog を見ると、次のようになります。
Affected parameters are:
logtoconsole =
logfile = C:\AuditStreams\NW\AuditStreamService.InstallLog
assemblypath = C:\AuditStreams\NW\AuditStreamService.exe
servicename = AuditStream-NW
これは正しいように見えますが、サービスの OnStart 内に、ServiceName を個人用ログ ファイルに出力する行があります。しかし、ServiceNameは常にAuditStreamServiceであると言われています
この場合、AuditStream-NWと言ってもらいたいと思っていました...誰かが私が間違っていることを理解できますか?
追加:
これらの名前を異なるものにしたい理由は、各サービスが MemoryMappedFile も作成するためです。元々、その非永続的な mmf の名前は常に"AuditStream-" + HubName
(構成ファイル内で決定される) ように設定していましたが、現在は外部プログラムです。 mmf を読み取ることによってサービスが何を行っているかを監視しますが、サービス構成ファイルを読み取ることを除けば、外部アプリケーションは mmf の名前を知りません。私の目標は、すべての名前を同じにすることServiceName = MMF Name = ServiceDisplayName
です.