"配置系统无法初始化"错误

时间:2014-08-05 12:58:06

标签: c# xml app-config

使用代码时我收到此异常:

var appSettings = ConfigurationManager.AppSettings; //Exception here
string result = appSettings["ILFSsqlServer"] ?? "Not Found"; //trying to get to this point

我不确定为什么,从此问题的先前答案中我认为我正在做他们的建议,但无济于事。

我的app.config是:

<?xml version="1.0"?>
<configuration>
  <configSections>
    <sectionGroup name="userSettings"
        type="System.Configuration.UserSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
    </sectionGroup>
  </configSections>
  <AppSettings>
    <add key="ILFSsqlServer" value="ODBC;DSN=sql server copycloas;Trusted_Connection=Yes;APP=Microsoft Office 2010;DATABASE=ILFSView;"/>
  </AppSettings>
</configuration>

1 个答案:

答案 0 :(得分:2)

在你的app.config上你应该写appSettings,小写字母A.