日期:2014-05-17  浏览次数:20497 次

在读取 app.config文件时 报配置系统未能初始化,请高手指导下
XML code
<?xml version="1.0"?>
配置如下
<configuration>
  <configSections>
    <section name="enterpriseLibrary.ConfigurationSource" type="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ConfigurationSourceSection, Microsoft.Practices.EnterpriseLibrary.Common, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null"/>
  </configSections>
  <startup>
    <supportedRuntime version="v2.0.50727"/>
  </startup>
  <connectionStrings>
    <add name="EquipmentsManagement" connectionString="Data Source=192.168.0.146;Initial Catalog=equipmenttest;Persist Security Info=True;User ID=equpment;Password=eqtest" providerName="System.Data.SqlClient"/>
  </connectionStrings>
  <log4net>
    <root>
      <level value="All"/>
      <appender-ref ref="RollingFileAppender"/>
    </root>
    <appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">
      <param name="File" value="log\equiepment.Log"/>
      <param name="AppendToFile" value="true"/>
      <param name="MaxSizeRollBackups" value="10"/>
      <param name="MaximumFileSize" value="10MB"/>
      <param name="RollingStyle" value="Size"/>
      <param name="StaticLogFileName" value="true"/>
      <layout type="log4net.Layout.PatternLayout">
        <param name="ConversionPattern" value="%d [%t] %-5p %c [%x] - %m%n"/>
      </layout>
    </appender>
  </log4net>
</configuration>




------解决方案--------------------
XML code

<configuration>
  <appSettings/>
  <configSections>
    <section name="enterpriseLibrary.ConfigurationSource" type="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ConfigurationSourceSection, Microsoft.Practices.EnterpriseLibrary.Common, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null"/>
  </configSections>
  <startup>
    <supportedRuntime version="v2.0.50727"/>
  </startup>
  <connectionStrings>
    <add name="EquipmentsManagement" connectionString="Data Source=192.168.0.146;Initial Catalog=equipmenttest;Persist Security Info=True;User ID=equpment;Password=eqtest" providerName="System.Data.SqlClient"/>
  </connectionStrings>
  <log4net>
    <root>
      <level value="All"/>
      <appender-ref ref="RollingFileAppender"/>
    </root>
    <appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">
      <param name="File" value="log\equiepment.Log"/>
      <param name="AppendToFile" value="true"/>
      <param name="MaxSizeRollBackups" value="10"/>
      <param name="MaximumFileSize" value="10MB"/>
      <param name="RollingStyle" value="Size"/>
      <param name="StaticLogFileName" value="true"/>
      <layout type="log4net.Layout.PatternLayout">
        <param name="ConversionPattern" value="%d [%t] %-5p %c [%x] - %m%n"/>
      </layout>
    </appender>
  </log4net>
</configuration>