我需要从使用App.config文件中获得“http://example.com”。如何将ConfigurationManager.AppSettings与自定义节一起使用?
但目前我使用:
string peopleXMLPath = ConfigurationManager.AppSettings["server"];
我不能得到的价值。
你能指出我做错了什么吗?
<?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>
http://haacked.com/archive/2007/03/11/custom-configuration-sections -in-3-easy-steps.aspx – GibboK
'ConfigurationManager.AppSettings [“MyAppSetting”]'只提供在配置文件中以''下的名称“MyAppSetting”为键名的设置。 –
检查此链接http://stackoverflow.com/questions/6329114/how-to-read-a-values-from-new-section-in-web-config –