【问题标题】:How to Set the Configuration File to current dll.config如何将配置文件设置为当前的 dll.config
【发布时间】:2017-08-04 05:10:31
【问题描述】:

当我启动我的 exe 时,配置文件设置为 mypp.exe.config。

在某些点之后,我希望它指向 mydll.config。

我正在尝试:

var configPath = AppDomain.CurrentDomain.SetupInformation.ConfigurationFile;
var Location = Assembly.GetExecutingAssembly().Location;

AppDomain.CurrentDomain.SetupInformation.ConfigurationFile = config.FilePath;

但是我设置断点查看的时候,配置文件还是设置为myapp.exe.config。

缺少什么?

【问题讨论】:

  • 我不相信应用程序开始运行后可以更改配置文件。
  • 我也被困在同一件事上……你有没有找到任何方法@simsons?

标签: c# .net configuration


【解决方案1】:

使用AppDomain.SetData:

AppDomain.CurrentDomain.SetData("APP_CONFIG_FILE", config.FilePath);

我找不到任何文档,但它对我有用。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-08-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-11-16
    相关资源
    最近更新 更多