Issue with Ent Lib 2.0 while migrating

Topics: Enterprise Library Core
Apr 17, 2008 at 2:13 PM
Our project was using .NET 1.1 framework with Enterprise library (EntLib) 1.1. Now we are migrating to .Net 2.0 and Enterprise library (EntLib) 2.0.
The configuration block of EntLib 2.0 is quite different from EntLib 1.1 and does not have a backward compatibility.

In my project I am having external Config files which are being refereed in the web.config file. Below are the details of my web.config and the external Config file that I am trying to fetch.
From my web.config file I am trying to read the value for ServiceInfo.

WEB.CONFIG

<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="enterpriselibrary.configurationSettings" type="System.Configuration.IgnoreSectionHandler, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</configSections>
<system.web>
</system.web>
<enterpriselibrary.configurationSettings xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" applicationName="WPDT" xmlns="http://www.microsoft.com/practices/enterpriselibrary/08-31-2004/configuration">
<configurationSections>
<configurationSection xsi:type="ReadOnlyConfigurationSectionData" name="cachingConfiguration" encrypt="false">
<storageProvider xsi:type="XmlFileStorageProviderData" name="XML File Storage Provider" path="cachingConfiguration.config" />
<dataTransformer xsi:type="XmlSerializerTransformerData" name="Xml Serializer Transformer">
<includeTypes />
</dataTransformer>
</configurationSection>
<configurationSection xsi:type="ReadOnlyConfigurationSectionData" name="exceptionHandlingConfiguration" encrypt="false">
<storageProvider xsi:type="XmlFileStorageProviderData" name="XML File Storage Provider" path="exceptionHandlingConfiguration.config" />
<dataTransformer xsi:type="XmlSerializerTransformerData" name="Xml Serializer Transformer">
<includeTypes>
<includeType name="LoggingExceptionHandlerData" type="Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.Configuration.LoggingExceptionHandlerData, Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging, Version=1.1.0.0, Culture=neutral, PublicKeyToken=47113fbddf3d3af8" />
</includeTypes>
</dataTransformer>
</configurationSection>
<configurationSection name="fcc.ApplicationAccount" encrypt="true">
<storageProvider xsi:type="XmlFileStorageProviderData" name="XML File Storage Provider" path="fcc.ApplicationAccount.config_INT" />
<dataTransformer xsi:type="XmlSerializerTransformerData" name="Xml Serializer Transformer">
<includeTypes />
</dataTransformer>
</configurationSection>
<configurationSection xsi:type="ReadOnlyConfigurationSectionData" name="loggingDistributorConfiguration" encrypt="false">
<storageProvider xsi:type="XmlFileStorageProviderData" name="XML File Storage Provider" path="loggingDistributorConfiguration.config" />
<dataTransformer xsi:type="XmlSerializerTransformerData" name="Xml Serializer Transformer">
<includeTypes />
</dataTransformer>
</configurationSection>
<configurationSection name="ServiceInfo" encrypt="false">
<storageProvider xsi:type="XmlFileStorageProviderData" name="XML File Storage Provider" path="ServiceInfo.config" />
<dataTransformer xsi:type="XmlSerializerTransformerData" name="Xml Serializer Transformer">
<includeTypes />
</dataTransformer>
</configurationSection>
</configurationSections>
<keyAlgorithmStorageProvider xsi:type="FileKeyAlgorithmPairStorageProviderData" name="File Key Algorithm Storage Provider" path="C:\\Views\\a398349\\a398349viewClientConfig\\vobs\\clientconfig\\FescoClientConfigServices\\FescoClientConfigServices.key">
<dpapiSettings xsi:nil="true" />
</keyAlgorithmStorageProvider>
<includeTypes />
</enterpriselibrary.configurationSettings>
</configuration>


External Config File ( ServiceInfo.config)
<ServiceInfo>
<xmlSerializerSection type="FescoClientConfigServices.Config.ConfigSettings, FescoClientConfigServices">
<ConfigSettings>
<Services>
<ServiceInfo InterfaceQName="Fesco.ClientConfiguration.Services.DC.Interfaces.IFundService" ClassQName="Fesco.ClientConfiguration.Services.DC.XdasImpl.XdasFundService" />
<ServiceInfo InterfaceQName="Fesco.ClientConfiguration.Services.DC.Interfaces.IMutualFundWindowService"
ClassQName="Fesco.ClientConfiguration.Services.DC.XdasImpl.XdasMutualFundWindowService" />
<ServiceInfo InterfaceQName="Fesco.ClientConfiguration.Services.DC.Interfaces.IPlanFundService"
ClassQName="Fesco.ClientConfiguration.Services.DC.XdasImpl.XdasPlanFundService" />
<ServiceInfo InterfaceQName="Fesco.ClientConfiguration.Services.DC.Interfaces.IPlanOnlineFundListService"
ClassQName="Fesco.ClientConfiguration.Services.DC.XdasImpl.XdasPlanOnlineFundListService" />
<ServiceInfo InterfaceQName="Fesco.ClientConfiguration.Services.DC.Interfaces.IPlanRptProductService"
ClassQName="Fesco.ClientConfiguration.Services.DC.XdasImpl.XdasPlanRptProductService" />
<ServiceInfo InterfaceQName="Fesco.ClientConfiguration.Services.DC.Interfaces.IPlanRptProductFundService"
ClassQName="Fesco.ClientConfiguration.Services.DC.XdasImpl.XdasPlanRptProductFundService" />
<ServiceInfo InterfaceQName="Fesco.ClientConfiguration.Services.DC.Interfaces.IPlanSourceService"
ClassQName="Fesco.ClientConfiguration.Services.DC.XdasImpl.XdasPlanSourceService" />
<ServiceInfo InterfaceQName="Fesco.ClientConfiguration.Services.DC.Interfaces.IFprsStateService"
ClassQName="Fesco.ClientConfiguration.Services.DC.XdasImpl.XdasFprsStateService" />
<ServiceInfo InterfaceQName="Fesco.ClientConfiguration.Services.DC.Interfaces.IPlanFundInclusionOrderService"
ClassQName="Fesco.ClientConfiguration.Services.DC.XdasImpl.XdasPlanFundInclusionOrderService" />
<ServiceInfo InterfaceQName="Fesco.ClientConfiguration.Services.DC.Interfaces.IAutoEnrollmentService"
ClassQName="Fesco.ClientConfiguration.Services.DC.XdasImpl.XdasAutoEnrollmentService" />
</Services>
</ConfigSettings>
</xmlSerializerSection>
</ServiceInfo>


In .EntLib 1.1 to read ServiceInfo section, we have used the below code.
object objConfigSection = ConfigurationManager.GetConfiguration("ServiceInfo");
ConfigSettings settings = (ConfigSettings) objConfigSection;

This Piece of code was able to read the external Config file (ServiceInfo.config) and return an object of type “FescoClientConfigServices.Config.ConfigSettings “.

Now using EntLib 2.0 we want to achieve the same result. We have tried various options to make this work but in vain.

Any input on this would be very helpful.

Thanks in advance.

Regards,
Abhishek Arun

Apr 17, 2008 at 9:19 PM
Hi,

EntLib's configuration builds on top of the System.Configuration functionality available since v2 of the .NET Framework. You can read about how to implement a custom configuration section in this msdn article http://msdn2.microsoft.com/en-us/library/2tw134k3.aspx. Additionally, there's a "Configuration-Migration" quick start showing how to work with the new configuration.

If you only used the configuration support in EntLib v1.1 to make it easier to define configuration, the standard .NET 2.0 support for extending the configuration schema might be all you need.

Fernando