【问题标题】:using elements in app.config file使用 app.config 文件中的元素
【发布时间】:2011-09-22 12:11:01
【问题描述】:

目前我的应用配置设置如下所示

<appSettings>
    <add key="ConnectionString" value="server=localhost;user=;port=;" />
    <add key="MS" value="MSr" />
    <add key="MassagesTable" value="Massages" />
  </appSettings>

我想在"MassagesTable" 下添加一个内部元素,名称为columnOneColumnTwo。我该怎么做,他们从代码中读取它。

目前我喜欢ConfigurationManager.AppSettings["ConnectionString"];

感谢您的帮助。

【问题讨论】:

标签: c# .net app-config


【解决方案1】:

你可以在这里找到一个例子:Custom type application settings in ASP.NET

基本上,您可以添加任何自定义对象作为设置,只要您使用“类型化设置”和 XML-serializable 类或具有类型转换器。为此,您应该使用 applicaitonSettings 部分而不是 appSettings

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2010-12-14
    • 1970-01-01
    • 1970-01-01
    • 2012-10-26
    • 2011-05-15
    • 2011-09-13
    • 2016-10-01
    • 1970-01-01
    相关资源
    最近更新 更多