使用appsettings,但“ConfigurationSettings”方法已过时

发布于 2024-11-16 01:17:17 字数 755 浏览 3 评论 0原文

我试图访问 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

夜未央樱花落 2024-11-23 01:17:17

添加对 System.Configuration.dll 的引用。

这是一个解释。

Add a reference to System.Configuration.dll.

Here's an explanation.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文