var config = ConfigurationManager.OpenExeConfiguration(Assembly.GetAssembly(typeof(ProjectInstaller)).Location);
            this.serviceInstaller1.ServiceName = config.AppSettings.Settings["ServiceName"].Value;

我发现在有些情况下读取应用程序的配置文件会出现ConfigurationManager.AppSettings读取不到的情况,而用上面的代码却可以。比如Windows Service 的Installer里面动态从配置文件读取ServiceName的时候。

相关文章:

  • 2021-06-03
  • 2021-05-29
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-24
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-01-17
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-09
相关资源
相似解决方案