使用appsettings,但“ConfigurationSettings”方法已过时
我试图访问 vb.net 2.0 Web 应用程序中的 appsettings 键值。
我已将密钥放入 app.config 文件中:
<appSettings>
<add key="DownloadURL" value="http://<myURL>/" />
</appSettings>
我已按照此处<的说明进行操作/a>,它说我需要像这样访问这个密钥:
URL = System.Configuration.ConfigurationSettings.AppSettings("DownloadURL")
但我收到以下消息:
公共共享只读属性 AppSettings() 作为 'System.Collections.Specialized.NameValueCollection' 已过时:'此方法已过时, 它已被替换为 System.configuration!System.configuration.configurationmanager.AppSettings'
我尝试用新方法替换旧方法,但它不存在。
奇怪的是,因为我在网络应用程序中做过类似的事情,而且它确实存在于那里。
I've trying to access an appsettings key value in my vb.net 2.0 web application.
I've put the key in the app.config file:
<appSettings>
<add key="DownloadURL" value="http://<myURL>/" />
</appSettings>
I've followed the instructions here, and it says that I need to access this key like so:
URL = System.Configuration.ConfigurationSettings.AppSettings("DownloadURL")
But I get the following message:
Public Shared Readonly property
AppSettings() As
'System.Collections.Specialized.NameValueCollection'
is obsolete: 'This method is obsolete,
it has been replaced by
System.configuration!System.configuration.configurationmanager.AppSettings'
I tried to replace the old method with the new one, but it does not exist.
Strange, since I've done a similar thing with a web app and it did exist there.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
添加对 System.Configuration.dll 的引用。
这是一个解释。
Add a reference to System.Configuration.dll.
Here's an explanation.