How can a Windows Service determine its ServiceName?

后端 未结 7 924
春和景丽
春和景丽 2020-11-27 05:53

I\'ve looked and couldn\'t find what should be a simple question:

How can a Windows Service determine the ServiceName for which it was started?

7条回答
  •  一个人的身影
    2020-11-27 06:38

    What's wrong with this.ServiceName, if you're inside the service.cs?

    i.e.:

    protected override void OnStart(string[] args)
        {
            Logger.Info($"{this.ServiceName} started on {Environment.MachineName}...");  
        }
    

提交回复
热议问题