2
我在新安裝的桌面下面的代碼中進行調試。檢查我的環境很簡單。 我通過互聯網搜索了錯誤,但沒有答案可以解決我的問題。我想也許這是由文件系統權限造成的。配置系統無法初始化/無法識別配置部分<SectionName>
static void Main(string[] args)
{
string test = ConfigurationManager.AppSettings["aaa"].ToString();
Console.WriteLine(test);
}
而且App.config中的樣子:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="aaa" value="bbb" />
</appSettings>
</configuration>
我得到了如下錯誤:
System.Configuration.ConfigurationErrorsException: Configuration system failed to initialize ---> System.Configuration.ConfigurationErrorsException: Unrecognized configuration section appSettings
at System.Configuration.ConfigurationSchemaErrors.ThrowIfErrors(Boolean ignoreLocal)
at System.Configuration.BaseConfigurationRecord.ThrowIfParseErrors(ConfigurationSchemaErrors schemaErrors)
at System.Configuration.BaseConfigurationRecord.ThrowIfInitErrors()
at System.Configuration.ClientConfigurationSystem.EnsureInit(String configKey)
--- End of inner exception stack trace ---
at System.Configuration.ClientConfigurationSystem.EnsureInit(String configKey)
at System.Configuration.ClientConfigurationSystem.PrepareClientConfigSystem(String sectionName)
at System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection(String sectionName)
at System.Configuration.ConfigurationManager.GetSection(String sectionName)
at System.Configuration.ConfigurationManager.get_AppSettings()