1

如果我为我的程序使用Microsoft 企业库的外部配置文件,那么企业库的所有配置都必须驻留在外部配置文件中吗?我还能在托管配置文件中保留部分配置吗?

4

3 回答 3

1

If I understand you correctly you want to configure Entlib in an external file, and override some settings on your app.config?

If that's the case, check the EntLib Hands-On Labs. Particularly take a look at the configuration HOL; it shows you how to inherit configuration from a shared location, and override it.

于 2011-02-11T15:35:57.437 回答
1

我正在使用企业库 5.0

我需要在 app.config 之外引用我的企业库配置。

我在自己的日志工厂中使用了以下内容:

var configSource = new FileConfigurationSource("EntiLib.config");
var logWriterFactory = new LogWriterFactory(configSource);
var logWriter = logWriterFactory.Create();

我能够在 CodePlex 上找到这个解决 方案

于 2011-02-18T20:28:46.630 回答
1

Nicolas 和 Peter 的良好链接。很高兴您发现动手实验室很有用。另外,请看一下我们为解释各种配置场景而编写的这一章,包括:

  • 从广泛的来源读取配置信息。
  • 跨多个应用程序强制执行通用配置设置。
  • 在应用程序之间共享配置设置。
  • 指定应用程序可以继承的一组核心配置设置。
  • 合并存储在共享位置的配置设置。
  • 为不同的部署环境创建不同的配置。
于 2011-02-19T17:21:12.673 回答