配置系统初始化失败;错误

本文关键字:错误 失败 初始化 系统 配置 | 更新日期: 2023-09-27 18:16:23

当使用代码时,我得到了这个异常:

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>

配置系统初始化失败;错误

在你的app.config中你应该写appSettings,小写a