two data configuration area conflicting

Topics: Data Access Application Block
Mar 8, 2007 at 3:58 PM
Hey All,

I am trying to install Enterprise Library Jan 2006 edition for it's Data Access library and am getting the following error when installing with another product that seems to use Data.Configuration.DatabaseSettings as well.

How can I configure this so there is no conflict?
// multi-line
Unable to cast object of type 'Ektron.ASM.Data.Configuration.DatabaseSettings' to type 'Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidCastException: Unable to cast object of type 'Ektron.ASM.Data.Configuration.DatabaseSettings' to type 'Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings'.
Source Error:
Line 297:                
Line 298:                    Database db = Microsoft.Practices.EnterpriseLibrary.Data.DatabaseFactory.CreateDatabase("myClientCustom");

I changed up my web.config as follows and maybe this is where I might need some correction:

// multi-line
<?xml version="1.0"?>
    <section name="MSDataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=, Culture=neutral, PublicKeyToken=null"/>
    <section name="dataConfiguration" type="Ektron.ASM.Data.Configuration.DatabaseSettings, Ektron.ASM.Data"/>
    <section name="DocumentManagerData" type="Ektron.ASM.AssetConfig.DocumentManagerData, Ektron.ASM.AssetConfig" restartOnExternalChanges="false" requirePermission="false"/>
    <section name="mediaSettings" type="System.Configuration.NameValueFileSectionHandler,System, Version=1.0.3300.0,Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
    <section name="analyticsSettings" type="System.Configuration.NameValueFileSectionHandler"/>
    <sectionGroup name="microsoft.web" type="Microsoft.Web.Configuration.MicrosoftWebSectionGroup">
      <section name="scripts" type="Microsoft.Web.Configuration.ScriptsSection"/>
      <section name="converters" type="Microsoft.Web.Configuration.ConvertersSection"/>
    <section name="webSearch" type="Ektron.Cms.WebSearch.Configuration, Ektron.Cms.WebSearch" allowDefinition="MachineToApplication"/>
  <DocumentManagerData configSource="AssetManagement.config"/>
    <!-- globally enables or disabled all visitor tracking -->
    <add key="enableAnalytics" value="true"/>
    <!-- appends the content_id and user_id to your IIS log -->
    <add key="appendToIISLog" value="false"/>
    <!-- number of page views before write -->
    <add key="recordsBeforeWrite" value="100"/>
    <!-- time, in seconds, before writing -->
    <add key="timeBeforeWrite" value="360"/>
    <!--FOR SQLSERVER-->
    <add name="Ektron.DbConnection" providerName="System.Data.SqlClient" connectionString="server=web-workstation\sql2005;database=myClient;Integrated Security=FALSE;user=sa;pwd=xxxx;"/>
    <add name="myClientCustom" providerName="System.Data.SqlClient" connectionString="server=web-workstation\sql2005;database=myClientCustom;Integrated Security=FALSE;user=sa;pwd=xxxx!;"/>
  <dataConfiguration defaultDatabase="Ektron.DbConnection" />
  <MSDataConfiguration defaultDatabase="myClientCustom" />

Mar 12, 2007 at 4:06 PM
Did that change in the configuration file work?

The DatabaseSettings Class in Enterprise Library specifies a particular configuration section name:

/// <summary>
/// The name of the data configuration section.
/// </summary>
public const string SectionName = "dataConfiguration";

so I don't think that is going to work.

You can try changing and recompiling the EntLib Source Code mentioned above to

/// <summary>
/// The name of the data configuration section.
/// </summary>
public const string SectionName = "MSDataConfiguration";

to work with the new configuration section name you mention above.

Keep in mind that most people will be using dataConfiguration as their configuration section name, however, so your application configuration will be different than The Standard and you will be supporting your own version of the DAAB.




David Hayden
Microsoft MVP C#
Mar 12, 2007 at 6:53 PM
Hey Dave,

Ok understood... I changed it up and it works as expected. Thanks for your response!!