Installing multiple instances of the same windows service on a server

前端 未结 10 1697
深忆病人
深忆病人 2020-12-07 08:21

So we\'ve produced a windows service to feed data to our client application and everything is going great. The client has come up with a fun configuration request that requ

10条回答
  •  一向
    一向 (楼主)
    2020-12-07 08:54

    The simplest approach is is based the service name on the dll name:

    string sAssPath = System.Reflection.Assembly.GetExecutingAssembly().Location;
    string sAssName = System.IO.Path.GetFileNameWithoutExtension(sAssPath);
    if ((this.ServiceInstaller1.ServiceName != sAssName)) {
        this.ServiceInstaller1.ServiceName = sAssName;
        this.ServiceInstaller1.DisplayName = sAssName;
    }
    

提交回复
热议问题