配置系统无法初始化' System.Configuration.ConfigurationErrorsException'发生在System.Configuration.dll中

时间:2018-03-13 15:56:12

标签: c# winforms app-config

首先,我在StackOverflow上搜索,也查看了所有相似的答案,但无法找到任何解决方案。

app.conf文件

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
   <configSections>
      <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
         <section name="dtaabse.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
      </sectionGroup>
  </configSections>
  <connectionstrings>
    <add name="Db" connectionstring="Data Source=(local);Initial Catalog =DV login pro; Integrated Security=true"
         providerName="System.Data.SqlClient"
/>
  </connectionstrings>

  <applicationSettings>
    <dtaabse.Properties.Settings>
      <setting name="setting" serializeAs="String">
        <value />
      </setting>
    </dtaabse.Properties.Settings>
  </applicationSettings>
</configuration>

form.cs档案

string connstring = ConfigurationManager.ConnectionStrings["Db"].ConnectionString;

只有此行显示错误。请帮我找到这个错误!

1 个答案:

答案 0 :(得分:0)

它的区分大小写。将connectionstringconnectionstrings更改为connectionStringconnectionStrings

<connectionStrings>
    <add name="Db" connectionString="Data Source=(local);Initial Catalog =DV login pro; Integrated Security=true"
     providerName="System.Data.SqlClient"
    />
 </connectionStrings>