System.Configuration.ConfigurationManager.GetSection

本文探讨了在.NET框架中使用ConfigurationSettings.GetConfig方法遇到的问题,并提供了如何正确使用ConfigurationManager.GetSection方法的解决方案,包括引入正确的程序集system.configuration.dll。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"></script>

好几次在代码中使用了System.Configuration.ConfigurationSettings.GetConfig方法,但每次使用之后都出现如下提示:



  但奇怪的是每次按系统提示调用System.Configuration.ConfigurationManager.GetSection方法时都出现以下错误:命名空间“System.Configuration”中不存在类型或命名空间名称“ConfigurationManager”(是缺少程序集引用吗?)。以前都尝试失败后就继续使用GetSection方法,今天再次尝试又出错,于是就去查阅了MSDN,关于ConfigurationManager类的说明如下:


关于ConfigurationSettings类的说明如下:

  哈哈,原来ConfigurationSetting属于system.dll程序集中,而ConfigurationManager属于system.configration.dll程序集中,系统默认引入的程序集中不包含system.configration.dll程序集,所以只需引用system.configration.dll程序集就可以了。
 

<?xml version=“1.0” encoding=“utf-8”?> <configuration> <configSections> <section name=“connectionSettings” type=“System.Configuration.AppSettingsSection” /> <section name=“communicationSettings” type=“System.Configuration.AppSettingsSection” /> <section name=“packageSettings” type=“System.Configuration.AppSettingsSection” /> <section name=“sessionSettings” type=“System.Configuration.AppSettingsSection” /> <section name=“analyticsSettings” type=“System.Configuration.AppSettingsSection” /> <section name=“webProxySettings” type=“System.Configuration.AppSettingsSection” /> <section name=“robotCacheSettings” type=“System.Configuration.AppSettingsSection” /> <section name=“robotJsSettings” type=“System.Configuration.AppSettingsSection” /> </configSections> <connectionSettings> <add key=“defaultServiceUrl” value=“https://cloud.uipath.com” /> </connectionSettings> <communicationSettings> <add key=“maxMessageSizeInMegabytes” value=“1” /> <add key=“installPackageTimeout” value=“00:20:00” /> <add key=“requestTimeout” value=“00:00:40” /> </communicationSettings> <packageSettings> <add key=“disableSecureXaml” value=“False” /> </packageSettings> <sessionSettings /> <analyticsSettings> <add key=“Telemetry.Enabled” value=“True” /> </analyticsSettings> <webProxySettings /> <robotCacheSettings /> <robotJsSettings /> </configuration>C#如何读取这个配置文件里的内容
最新发布
03-11
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值