How to get windows service name from app.config

后端 未结 2 701
我在风中等你
我在风中等你 2020-12-11 17:51

i have a app.config

  
    
    

        
相关标签:
2条回答
  • 2020-12-11 18:35

    problem is solved with this code

    public string GetServiceNameAppConfig(string serviceName)
    {
        var config = ConfigurationManager.OpenExeConfiguration(Assembly.GetAssembly(typeof(MyServiceInstaller)).Location);
        return config.AppSettings.Settings[serviceName].Value;
    }
    
    0 讨论(0)
  • 2020-12-11 18:44

    have you tried this - configurationmanager.appsettings["yourkey"]

    0 讨论(0)
提交回复
热议问题