3.1.0.0 - Setting up Web.config enterpriseLibrary.configurationSettings

Topics: Data Access Application Block
Jan 24, 2009 at 4:19 AM
Hello,

I am currently struggling with Enterprise Library 3.1.0.0 .  I have started a .NET (2.0) project, something I have not done in quite some time.  Last time I worked with .NET, the company I was working for was using Enterprise Library 1.0.5 so as I am trying to look at old projects to remember things, it is not helping me much when it comes to configuration settings for EL 3.1.0.0 .
 

I am getting the oh so popular error:
"Invalid section name. The section 'dataConfiguration' does not exist in the requested configuration file 'C:\Users\Justin\Documents\Visual Studio 2005\Projects\BusinessManager\BusinessManager\web.config' or the file 'C:\Windows\Microsoft.NET\Framework\v2.0.50727\Config\machine.config'. Make sure that the 'enterpriseLibrary.configurationSections' configuration section exists in one of the files and that the section 'dataConfiguration' is defined."

My Web.config looks like this:
<?xml version="1.0"?>
<configuration>
  <configSections>
    <section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
  </configSections>
  <dataConfiguration defaultDatabase="BusinessManager">
  <connectionStrings>
    <add name="BusinessManager" connectionString="Dsn=MySQL-CBS;uid=root"
      providerName="System.Data.Odbc" />
  </connectionStrings>
  </dataConfiguration>
  <system.web>
    <!--
            Set compilation debug="true" to insert debugging
            symbols into the compiled page. Because this
            affects performance, set this value to true only
            during development.

            Visual Basic options:
            Set strict="true" to disallow all data type conversions
            where data loss can occur.
            Set explicit="true" to force declaration of all variables.
        -->
    <compilation debug="true" strict="false" explicit="true" />
    <pages>
      <namespaces>
        <clear />
        <add namespace="System" />
        <add namespace="System.Collections" />
        <add namespace="System.Collections.Specialized" />
        <add namespace="System.Configuration" />
        <add namespace="System.Text" />
        <add namespace="System.Text.RegularExpressions" />
        <add namespace="System.Web" />
        <add namespace="System.Web.Caching" />
        <add namespace="System.Web.SessionState" />
        <add namespace="System.Web.Security" />
        <add namespace="System.Web.Profile" />
        <add namespace="System.Web.UI" />
        <add namespace="System.Web.UI.WebControls" />
        <add namespace="System.Web.UI.WebControls.WebParts" />
        <add namespace="System.Web.UI.HtmlControls" />
      </namespaces>
    </pages>
    <!--
            The <authentication> section enables configuration
            of the security authentication mode used by
            ASP.NET to identify an incoming user.
        -->
    <authentication mode="Windows" />
    <!--
            The <customErrors> section enables configuration
            of what to do if/when an unhandled error occurs
            during the execution of a request. Specifically,
            it enables developers to configure html error pages
            to be displayed in place of a error stack trace.

        <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
            <error statusCode="403" redirect="NoAccess.htm" />
            <error statusCode="404" redirect="FileNotFound.htm" />
        </customErrors>
        -->
  </system.web>
</configuration>

And my dataconfiguration.config file looks like this:
<?xml version="1.0" encoding="utf-8"?>
<dataConfiguration>
    <xmlSerializerSection
      type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings,
      Microsoft.Practices.EnterpriseLibrary.Data">
        <enterpriseLibrary.databaseSettings
          xmlns:xsd="http://www.w3.org/2001/XMLSchema"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xmlns="http://www.microsoft.com/practices/enterpriselibrary/08-31-2004/data"
          defaultInstance="BusinessManager">
            <databaseTypes>
                <databaseType
                  name="MySql"
                  type="Devart.Data.MySql.EnterpriseLibrary.MySqlDatabase, Devart.Data.MySql.EnterpriseLibrary" />
            </databaseTypes>
            <instances>
                <instance
                  name="BusinessManager"
                  type="MySql"
                  connectionString="BusinessManager" />
            </instances>
            <connectionStrings>
                <connectionString name="BusinessManager">
                    <parameters>
                        <parameter name="host" value="localhost" isSensitive="false" />
                        <parameter name="user id" value="root" isSensitive="false" />
                        <parameter name="password" value="" isSensitive="false" />
                        <parameter name="port" value="3306" isSensitive="false" />
                        <parameter name="database" value="cbs" isSensitive="false" />
                    </parameters>
                </connectionString>
            </connectionStrings>
        </enterpriseLibrary.databaseSettings>
    </xmlSerializerSection>
</dataConfiguration>

I know in the old days you would have something like this at the bottom of your Web.config .... What would be the equivalent of this for 3.1.0.0
<enterpriselibrary.configurationSettings xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" applicationName="Application" xmlns="http://www.microsoft.com/practices/enterpriselibrary/08-31-2004/configuration">
        <configurationSections>
            <configurationSection xsi:type="ReadOnlyConfigurationSectionData" name="dataConfiguration" encrypt="false">
                <storageProvider xsi:type="XmlFileStorageProviderData" name="XML File Storage Provider" path="dataConfiguration.config"/>
                <dataTransformer xsi:type="XmlSerializerTransformerData" name="Xml Serializer Transformer">
                    <includeTypes/>
                </dataTransformer>
            </configurationSection>
        </configurationSections>
        <keyAlgorithmStorageProvider xsi:nil="true"/>
        <includeTypes/>
  </enterpriselibrary.configurationSettings>

I will be grateful for any help!  Thanks!





Jan 24, 2009 at 3:41 PM
Hi,

Please see this thread if this helps:
http://www.codeplex.com/entlib/Thread/View.aspx?ThreadId=6910


Valiant Dudan
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com
Jan 25, 2009 at 6:52 AM
Thanks so much for the link but it did not seem to help me any.  To be clearer, I am certain the dataConfiguration section is in both the Web.config (as shown above) and machine.config (because I put the code below in it after seeing this error).

<configSections>
    <section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
  </configSections>

I am mostly worried about this part of the error:
Make sure that the 'enterpriseLibrary.configurationSections' configuration section exists in one of the files and that the section 'dataConfiguration' is defined."
Jan 26, 2009 at 1:45 PM
Hi,

This is a bit weird, your config looks good, first, have you verified that the file that the entlib is looking for is present in the directory that it being looked at? Can you please give more details about your application? Is it a application that is being migrated from a previous version of .NET? Or do you have a quick repro steps for me.. or if you could send me a sample solution..


Valiant Dudan
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com



Jan 27, 2009 at 6:43 AM
Just to add, did you add the dataconfiguration section through the config tool or you just copied it from another application? If you did the latter, verify that you can open it in the config tool without errors.   You can also check out this post, might be worth the look.. http://www.codeplex.com/entlib/Thread/View.aspx?ThreadId=32681


Sarah Urmeneta
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com