Error getting Data configuration

Topics: Data Access Application Block, General discussion
Feb 17, 2011 at 4:40 PM

I have problem creating Database instance using Data Access block using EntLib 5.0.

I am using local copies of the assemblies. The error is reading from configuration, so I wrote a simple code to get all Database instances from config file. It works on a PC that has EntLIb 5.0 installed (and later uninstalled). But it does not read the entries on a PC that has only the local copies of the assemblies.

The code and the config files are below. I am using Oracle data provider, if that makes any difference.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Practices.EnterpriseLibrary.Common.Configuration;
using Microsoft.Practices.EnterpriseLibrary.Data;

namespace ReadEntLibConfig
{
    class Program
    {
        static void Main(string[] args)
        {
            var databaseList = EnterpriseLibraryContainer.Current.GetAllInstances<Database>();
            if (databaseList.Count() == 0) { Console.WriteLine("No database config entries found"); }
            else
            {
                Console.WriteLine("Data section entries");
                foreach (Database item in databaseList)
                {
                    Console.WriteLine(item.ConnectionString);
                    Console.WriteLine(Environment.NewLine);
                }
            }
            
        }
    }
}
My config file:
<?xml version="1.0"?>
<configuration>
  <configSections>
  <section name="loggingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSettings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true"/>
  <section name="exceptionHandling" type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Configuration.ExceptionHandlingSettings, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true"/>
  <section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true"/>
    </configSections>
  <dataConfiguration defaultDatabase="appConnection"/>
  <connectionStrings>
    <add name="appConnection" connectionString="user ID=user id;Password=;data source=data_source; Enlist=True;Pooling=true;Connection Lifetime=120;Min Pool Size=1;Max Pool Size=150;" providerName="Oracle.DataAccess.Client"/>
  </connectionStrings>
  <loggingConfiguration name="Logging Application Block" tracingEnabled="true" defaultCategory="Generic" logWarningsWhenNoCategoriesMatch="true">
    <listeners>
      <add name="Exceptions" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" fileName="../log/trace.log" header="----------------------------------------" footer="----------------------------------------" formatter="" traceOutputOptions="None"/>
    </listeners>
    <formatters>
      <add type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" template="{severity} | {eventid} | {processName} | {timestamp} | {message}" name="ClientLogger"/>
    </formatters>
    <categorySources>
      <add switchValue="All" name="Generic">
        <listeners>
          <add name="Exceptions"/>
        </listeners>
      </add>
    </categorySources>
    <specialSources>
      <allEvents switchValue="All" name="All Events"/>
      <notProcessed switchValue="All" name="Unprocessed Category"/>
      <errors switchValue="All" name="Logging Errors &amp; Warnings">
        <listeners>
          <add name="Exceptions"/>
        </listeners>
      </errors>
    </specialSources>
  </loggingConfiguration>
  <exceptionHandling>
    <exceptionPolicies>
      <add name="Exception Policy">
        <exceptionTypes>
          <add name="Exception" type="System.Exception, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" postHandlingAction="NotifyRethrow">
            <exceptionHandlers>
              <add name="Logging Handler" type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.LoggingExceptionHandler, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" logCategory="Generic" eventId="100" severity="Error" title="Exception Handling" formatterType="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.TextExceptionFormatter, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" priority="0"/>
            </exceptionHandlers>
          </add>
        </exceptionTypes>
      </add>
    </exceptionPolicies>
  </exceptionHandling>
</configuration>

Feb 17, 2011 at 10:59 PM

It should work as long as the assemblies are present.  Are you encountering an exception or does the databaseList.Count() only return zero?  Did you use the same test project on the machine which has entlib installed and on the machine which has no entlib installed?

 

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

Feb 18, 2011 at 1:21 AM

Thanks for the reply. The culprit was the Oracle data provider (Odp.net) being a 32 bit assembly. The server is 2008 R2.