相关疑难解决方法(0)

如何将ConfigurationManager.AppSettings与自定义部分一起使用?

我需要使用App.config文件获取" http://example.com ".

但目前我正在使用:

string peopleXMLPath = ConfigurationManager.AppSettings["server"];
Run Code Online (Sandbox Code Playgroud)

我无法获得价值.

你能指出我做错了什么吗?

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <configSections>
    <section name="device" type="System.Configuration.SingleTagSectionHandler" />
    <section name="server" type="System.Configuration.SingleTagSectionHandler" />
  </configSections>
  <device id="1" description="petras room" location="" mall="" />
  <server url="http://example.com" />
</configuration>
Run Code Online (Sandbox Code Playgroud)

.net c# wpf appsettings

9
推荐指数
1
解决办法
4万
查看次数

如何从 C# webconfig 小节获取属性?

我尝试从一个小节中获取所有属性,但该节有很多小节并且应用程序无法识别,我该怎么办?这是我的网络配置:

<configSections>
    <section name="Seccion" type="ManejoConfiguracion.SeccionConfig,ManejoConfiguracion"/>
   </configSections>

  <Seccion>
    <BD>
    <add key="name" value="dbKey" />
    <add key="user" value="userBD" />
    <add key="pass" value="123BD" />
    </BD>

    <ReportingService>
    <add key="name" value="Reporting" />
    <add key="user" value="userReport" />
    </ReportingService>

   </Seccion>
</configuration>
Run Code Online (Sandbox Code Playgroud)

c# configurationmanager web-config-transform

2
推荐指数
1
解决办法
2202
查看次数