SqlConfigurationSource Problems!

Topics: Building and extending application blocks, Enterprise Library Core, Exception Handling Application Block, General discussion
Jan 13, 2009 at 1:14 PM
Hi,

I want to use SqlConfigurationSource. I'm using enterprise library 4.1. I managed to get that "Sql Configuration Source" option in the enterprise library console application. But when I run my application I get a runtime error.

My app.config looks like this

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <section name="enterpriseLibrary.ConfigurationSource" type="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ConfigurationSourceSection, Microsoft.Practices.EnterpriseLibrary.Common, Version=4.1.0.0, Culture=neutral, PublicKeyToken=null" requirePermission="false" />
    <section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=4.1.0.0, Culture=neutral, PublicKeyToken=null" />
  </configSections>
  <enterpriseLibrary.ConfigurationSource selectedSource="Sql Configuration Source">
    <sources>
      <add name="Sql Configuration Source" type="Microsoft.Practices.EnterpriseLibrary.SqlConfigurationSource.SqlConfigurationSource, Microsoft.Practices.EnterpriseLibrary.SqlConfigurationSource, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null"
        connectionString="Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=TestDB;Data Source=WW009861\SQLEXPRESS"
        getStoredProcedure="EntLib_GetConfig" setStoredProcedure="EntLib_SetConfig"
        refreshStoredProcedure="UpdateSectionDate" removeStoredProcedure="EntLib_RemoveSection" />
      <add name="System Configuration Source" type="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.SystemConfigurationSource, Microsoft.Practices.EnterpriseLibrary.Common, Version=4.1.0.0, Culture=neutral, PublicKeyToken=null" />
    </sources>
  </enterpriseLibrary.ConfigurationSource>
</configuration>

I've also added the Exception Handling Application block. But, as I'm using SqlConfigurationSource its settings are stored in the database.

The error I get is this

System.Configuration.ConfigurationErrorsException was unhandled by user code
  Message="Unrecognized attribute 'connectionstring'. Note that attribute names are case-sensitive. (C:\\R&D\\SQLConfigSourceDemo\\SQLConfigSourceDemo\\bin\\Debug\\SQLConfigSourceDemo.vshost.exe.Config line 10)"
  Source="System.Configuration"
  BareMessage="Unrecognized attribute 'connectionstring'. Note that attribute names are case-sensitive."
  Filename="C:\\R&D\\SQLConfigSourceDemo\\SQLConfigSourceDemo\\bin\\Debug\\SQLConfigSourceDemo.vshost.exe.Config"
  Line=10
  StackTrace:
       at System.Configuration.ConfigurationElement.DeserializeElement(XmlReader reader, Boolean serializeCollectionKey)
       at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.NamedConfigurationElement.DeserializeElement(XmlReader reader)
       at Microsoft.Practices.EnterpriseLibrary.Common.Configuration.PolymorphicConfigurationElementCollection`1.OnDeserializeUnrecognizedElement(String elementName, XmlReader reader)
       at System.Configuration.ConfigurationElement.DeserializeElement(XmlReader reader, Boolean serializeCollectionKey)
  InnerException:
-------------------------------------------------------------------------------------------------------------------------------------

I'm not able to get around this issue. Please let me know if you guys have any idea about this. Thanks in advance. :)

Jan 14, 2009 at 6:57 AM
Hi,

Try adding a reference to Microsoft.Practices.EnterpriseLibrary.SqlConfigurationSource.dll and  Microsoft.Practices.EnterpriseLibrary.SqlConfigurationSource.Design.dll

Hope this helps.


Valiant Dudan
Global Technology and Solutions
Avanade, Inc.
entlib.support@avanade.com
Jan 14, 2009 at 7:09 AM
Hey,

Thanks a lot, that works.