【问题标题】:How can I load a config file from different assembly in asp.net?如何从 asp.net 中的不同程序集加载配置文件?
【发布时间】:2009-03-20 11:12:39
【问题描述】:

我正在使用来自 Enterprise Lib 的验证应用程序块,并在与实体对象位于同一程序集中的 validation.config 中定义了我的验证规则(因此我可以在后端和在网站上)。

但是如何从实体程序集获取validation.config 到网站程序集的web.config 中?

【问题讨论】:

    标签: asp.net validation configuration assemblies


    【解决方案1】:

    如果您的问题是关于加载非标准 App.config 或 web.config 文件的配置文件,ConfigurationManager 有一个您可以尝试的方法。

    System.Configuration.Configuration config =
         ConfigurationManager.OpenExeConfiguration(@"pathToFile\Config.dll");
    

    这将尝试加载一个名为 Config.dll.config 的文件。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-03-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-12-03
      • 2023-03-02
      • 2017-09-26
      相关资源
      最近更新 更多