检索appsettings我做错了什么?
在app.config
我有:
...
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2"/>
</startup>
<appSettings>
<add key="culture" value="cs-CZ"/>
</appSettings>
</configuration>
我正在尝试检索culture
值:
Dim culture = ConfigurationManager.AppSettings("culture").ToString()
但culture
始终会产生Nothing
检索appsettings我做错了什么?
这是我的整个app.config文件:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<globalization uiculture="cs-CZ" culture="cs-CZ">
</globalization>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<section name="WindowsApplication1.My.MySettings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false"/>
</sectionGroup>
</configSections>
<system.diagnostics>
<sources>
<!-- This section defines the logging configuration for My.Application.Log -->
<source name="DefaultSource" switchName="DefaultSwitch">
<listeners>
<add name="FileLog"/>
<!-- Uncomment the below section to write to the Application Event Log -->
<!--<add name="EventLog"/>-->
</listeners>
</source>
</sources>
<switches>
<add name="DefaultSwitch" value="Information"/>
</switches>
<sharedListeners>
<add name="FileLog" type="Microsoft.VisualBasic.Logging.FileLogTraceListener, Microsoft.VisualBasic, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" initializeData="FileLogWriter"/>
<!-- Uncomment the below section and replace APPLICATION_NAME with the name of your application to write to the Application Event Log -->
<!--<add name="EventLog" type="System.Diagnostics.EventLogTraceListener" initializeData="APPLICATION_NAME"/> -->
</sharedListeners>
</system.diagnostics>
<userSettings>
<WindowsApplication1.My.MySettings>
<setting name="txtPatientName" serializeAs="String">
<value>Patient Name</value>
</setting>
<setting name="datastorage" serializeAs="String">
<value/>
</setting>
</WindowsApplication1.My.MySettings>
</userSettings>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.2"/>
</startup>
<appSettings>
<add key="culture" value="cs-CZ"/>
</appSettings>
</configuration>