打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
ConfigurationSettings.AppSettings 已过时
  警告"System.Configuration.ConfigurationSettings.AppSettings”已过时,解决办法


今天用VS2010开发一个WebPart时,里面写了一个连接数据库的语句。


其中字符串


string cnnStr = System.Configuration.ConfigurationSettings.AppSettings["cnn"];


得出以下的警告


“System.Configuration.ConfigurationSettings.AppSettings”已过时:“"This method is obsolete, it has been replaced by System.Configuration!System.Configuration.ConfigurationManager.AppSettings。


 


直接把ConfigurationSettings写成ConfigurationManager,但是提示没有ConfigurationManager语句。


 


于是,在VS右边的“解决方案”中点“引用”,在.net处引入System.configuration.


然后,在空间写上 Using System.Configuration;


 


最后,再把ConfigurationSettings写成ConfigurationManager。这样就OK了。
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
应用程序配置和动态加载7
C# 读写Config文件(App.config)
C#获取web.config配置文件内容
ConfigurationManager类正确引用方法
配置文件app.config/web.config的增删改操作 - 洞幺人生 - 博客园
一种强行指定dll assembly读取其相应*.dll.config配置文件的方法(又名...
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服