ESB Toolkit 2.1 mess up Enterprise Library 5.0 big time

Published on : Sep 2, 2011

Category : General

Saravana

Author

I spend nearly 5 hours so far today trying to configure Enterprise Library 5.0 for one of our projects. The machine I’m working on got ESB 2.1 installed previously. ESB Toolkit 2.1 utilises Enterprise Library 4.1. Among the various application blocks, it takes advantage of ConfigurationSource to point to ESB specific configuration information (esb.config and SSOConfigurationSource) from machine.config file. When you open the machine.config file after ESB Toolkit 2.1 installation you will see the following information. <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=31bf3856ad364e35″ /> <enterpriseLibrary.ConfigurationSource selectedSource=”ESB File Configuration Source”> <sources> <add name=”ESB File Configuration Source” type=”Microsoft.Practices.EnterpriseLibrary.Common.Configuration.FileConfigurationSource, Microsoft.Practices.EnterpriseLibrary.Common, Version=4.1.0.0,Culture=neutral, PublicKeyToken=31bf3856ad364e35″ filePath=”C:Program Files (x86)Microsoft BizTalk ESB Toolkit 2.1esb.config” /> <add name=”ESB SSO Configuration Source” type=”Microsoft.Practices.ESB.SSOConfigurationProvider.SSOConfigurationSource, Microsoft.Practices.ESB.SSOConfigurationProvider, Version=2.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35″ applicationName=”” description=”Configuration Data” contactInfo=”” userGroupName=”” adminGroupName=”” /> </sources> </enterpriseLibrary.ConfigurationSource> This will break all the applications that uses Enterprise Library 5.0, when you try to initialize the Enterprise Library objects you will encounter errors as shown below. [A]Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ConfigurationSourceSection cannot be cast to [B]Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ConfigurationSourceSection. Type A originates from ‘Microsoft.Practices.EnterpriseLibrary.Common, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35’ in the context ‘Default’ at location ‘C:WindowsassemblyGAC_MSILMicrosoft.Practices.EnterpriseLibrary.Common4.1.0.0__31bf3856ad364e35Microsoft.Practices.EnterpriseLibrary.Common.dll’. Type B originates from ‘Microsoft.Practices.EnterpriseLibrary.Common, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35’ in the context ‘Default’ at location ‘C:WindowsassemblyGAC_MSILMicrosoft.Practices.EnterpriseLibrary.Common5.0.505.0__31bf3856ad364e35Microsoft.Practices.EnterpriseLibrary.Common.dll’ There is a suggestion on the BizTalk forum for this issue http://social.msdn.microsoft.com/Forums/en-CA/biztalkesb/thread/8dc6ecda-862c-415a-912c-8215caa67a85 but that doesn’t seem to work. When you try to use <enterpriseLibrary.ConfigurationSource selectedSource=”Local Application Configuration Source”> in your configuration file, you will receive the following error “Configuration system failed to initialize, Section or group name ‘enterpriseLibrary.ConfigurationSource’ is already defined. Updates to this may only occur at the configuration level where it is defined.“. That’s because the section is already added to the machine.config file by EST Toolkit 2.1 installation. I couldn’t find a solution to the problem. I’m just posting this so people are aware of the consequences, before installing ESB Toolkit 2.1.