none
ESB.Config Hijacks All Enterprise Library Apps Machine-Wide

    Question

  • I installed ESB Toolkit 2.0 on a computer that already had other apps (completely unrelated to BizTalk) that use Enterprise Library 4.1. Now those other apps crash because Enterprise Library has stopped looking for configuration data in their app.exe.config or web.config files. For example, a call to DatabaseFactory.CreateDatabase("myDatabase") will fail because Enterprise Libary doesn't look in the app's config file for the connection string. The exception message is:

    System.Configuration.ConfigurationErrorsException: The requested database myDatabase is not defined in configuration..

    However, if I put the connection string in the Toolkit's esb.config file, the exception goes away. So ESB Toolkit is forcing every app on my machine to store all its Enterprise Library configuration settings in esb.config.

    Even stranger, if I try to edit an application's app.config or web.config file with the Enterprise Library Configuration Editor (either the stand-alone or Visual Studio versions), the Editor tries to replace all the settings in the file with the settings from esb.config!

    This has to be a bug. How do I fix?

    Thursday, June 25, 2009 2:49 PM

Answers

  • Hernan,

    Your solution, as stated, doesn't work. But it's close.

    You can't use "whatever section name you want to" . The section name _must_ be "enterpriseLibrary.ConfigurationSource". This value is hard coded in Enterprise Library (see ConfigurationSourceSection.cs lines 33-42).

    If I paste your changes into my app./web.config file, but change the section's name from "enterpriseLibrary.ConfigurationSource.Local" to "enterpriseLibrary.ConfigurationSource", then Enterprise Library will get its runtime configuration from my file instead of esb.config, and thus my app will not crash.

    But:

    1. It's still impossible to edit my app./web.config file with the Enterprise Library Configuration Editor (either the stand-alone or Visual Studio versions). When I try to save changes the editor complains, "Cannot add a Configuration Section with the same name that already exists." You can blame this on the EntLib Editor, but the ESB Toolkit should have been responsible to avoid the problem.

    2. The EntLib documentation plainly says, "you should not store Enterprise Library configuration information in the Machine.config file." See http://msdn.microsoft.com/en-us/library/dd139957.aspx#Configuration_Tool_Usage_Notes. So why does ESB Toolkit do precisely that? Why couldn't it use BTSNTSvc.exe.config instead?

    Turning that question around, even though ESB Toolkit 2.0 no longer includes source code, is there any reason a customer couldn't remove all ESBT changes from machine.config and put them in BTSNTSvc.exe.config and/or any other ESBT app.config or web.config files instead?

    3. The fact that installing ESBT alters machine.config in ways that can break other EntLib-consuming apps should be disclosed in the readme file and in the installation instructions in the documentation.

    Sorry to  sound critical, but this was a time-consuming problem.

    Richard
    Friday, June 26, 2009 5:08 AM

All replies

  • Hi Richard,

    This behavior is by design in ESB since the config source in machine.config file is pointing to esb.config file. This is a feature of EntLib where will take the default config source from machine.config if you don't override it by defining another config source in you application config file.
    If you want to leave the ESB configuration and also have your own apps working with your own config file, then you may add this section to your own configs like this:

    In
    <configSections>  add:

    <section name="enterpriseLibrary.ConfigurationSource.Local" type="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ConfigurationSourceSection, Microsoft.Practices.EnterpriseLibrary.Common, Version=4.1.0.0,Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>

    Where you may use whatever section name you want to (in this case; enterpriseLibrary.ConfigurationSource.Local):

     

    <enterpriseLibrary.ConfigurationSource.Local selectedSource="Portal File Configuration Source">

        <sources>

          <add name="Local File Configuration Source"

               type="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.FileConfigurationSource, Microsoft.Practices.EnterpriseLibrary.Common, Version=4.1.0.0,Culture=neutral, PublicKeyToken=31bf3856ad364e35" filePath="web.config"/>

        </sources>

    </enterpriseLibrary.ConfigurationSource.Local>

     

    Notice that you can use in filePath  a value of “web.config” or your app config file.


    Regards,

    Hernan

     

     

     



    Thursday, June 25, 2009 10:31 PM
  • Hernan,

    Your solution, as stated, doesn't work. But it's close.

    You can't use "whatever section name you want to" . The section name _must_ be "enterpriseLibrary.ConfigurationSource". This value is hard coded in Enterprise Library (see ConfigurationSourceSection.cs lines 33-42).

    If I paste your changes into my app./web.config file, but change the section's name from "enterpriseLibrary.ConfigurationSource.Local" to "enterpriseLibrary.ConfigurationSource", then Enterprise Library will get its runtime configuration from my file instead of esb.config, and thus my app will not crash.

    But:

    1. It's still impossible to edit my app./web.config file with the Enterprise Library Configuration Editor (either the stand-alone or Visual Studio versions). When I try to save changes the editor complains, "Cannot add a Configuration Section with the same name that already exists." You can blame this on the EntLib Editor, but the ESB Toolkit should have been responsible to avoid the problem.

    2. The EntLib documentation plainly says, "you should not store Enterprise Library configuration information in the Machine.config file." See http://msdn.microsoft.com/en-us/library/dd139957.aspx#Configuration_Tool_Usage_Notes. So why does ESB Toolkit do precisely that? Why couldn't it use BTSNTSvc.exe.config instead?

    Turning that question around, even though ESB Toolkit 2.0 no longer includes source code, is there any reason a customer couldn't remove all ESBT changes from machine.config and put them in BTSNTSvc.exe.config and/or any other ESBT app.config or web.config files instead?

    3. The fact that installing ESBT alters machine.config in ways that can break other EntLib-consuming apps should be disclosed in the readme file and in the installation instructions in the documentation.

    Sorry to  sound critical, but this was a time-consuming problem.

    Richard
    Friday, June 26, 2009 5:08 AM
  • Richard,

    Your troubleshooting is exactly what I ran into and is probably the best solution.  One behavior I noticed though is that the stand-alone tool would throw the error as you mention, but will still save the file.  Although not clean, it at least allows a visual designer over digging into the xml configuration.

    One of the  reasons  the configuration source is in the machine.config is because of the many external services that use the configuration settings.   Also many of the components can be used completely outside of BizTalk.  If you look at ESB Guidance 2.0 CTP2 you will notice many of the core components are used outside the context of BizTalk especially in unit tests, but require the esb.config to work correctly.  Having a global configuration source versus many individual application files is much easier to manage.  If for some reason the esb.config file needed to be moved there is currently only once place to make that change versus many.  Also any applications using ESB components will run correctly on a server with ESB Toolkit installed without needing to include the configuration source.

    I think you have some very valid points though and is good feedback for the development team.  I hope to see support for this scenario in future versions of the Enterprise Library configuration tool, but regardless calling it out in documentation is a good idea.


    Thanks,
    Brendon


    Brendon Birdoes
    Friday, June 26, 2009 6:25 AM
    Moderator
  • One more issue:

    ESBT 2.0 installs EntLib DLLs in the global assembly cache, and when you uninstall ESBT the MSI removes them from the GAC. This will break any other apps on the machine that depend on the GAC containing those DLLs.

    It's easy to fix: restore the DLLs to the GAC. But the problem should be disclosed in ESBT documentation.
    Friday, June 26, 2009 1:32 PM
  • Hi,

    We need to deploy the ESB Toolkit on multiple developer and server machines within an enterprise environment. The deployment of various softwares to the machines is done via automated configuration scripts and the intention was to deploy the ESB Toolkit 2.0 (with configuration) in a similar way.

     

    The resolution described in this thread works i.e. add enterpriselibrary.confguration sections in each config file, but its a manual step and needs to be performed on all configuration files for any application that needs to access entlib functionality i.e. web.config, <appname>.exe.config  and we already have applications that use enterprise library 4.1 config files.

     

    In this scenario, what could be the approach to do automated deploy of the ESB Toolkit to multiple machines?

     

    Any suggestions are welcome.

    Regards,
    Gautam

    Tuesday, July 07, 2009 12:05 PM
  • Hi Richard,

    We need the EntLib DLL's in the GAC too and we do it (GACing the EntLib DLL's) as part of our application deployment via an MSI package. This way uninstalling the ESBT does not remove the EntLib assemblies from the GAC.

    Maybe this approach could work for you too

    Regards,
    Gautam
    Tuesday, July 07, 2009 12:12 PM
  • Hi,

    I am trying to extend enterprise library to perform Data Caching using Web Services in Enterprise Library (http://www.devx.com/dotnet/Article/35285 original article)

    I have modified the enterprise library 3.0 source code and have create signed assemblies.
    while the setup works well on my development machine but I am facing an issue while deploying this setup on a server that has ESB installed

    below is my partial web.config settings
    <configuration>
      <configSections>
        <section name="enterpriseLibrary.ConfigurationSource" type="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ConfigurationSourceSection, Microsoft.Practices.EnterpriseLibrary.Common, Version=3.0.0.0, Culture=neutral, PublicKeyToken=c6897d156a3b3b19" />
        <section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=3.0.0.0, Culture=neutral, PublicKeyToken=c6897d156a3b3b19" />
        <section name="cachingConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Caching.Configuration.CacheManagerSettings, Microsoft.Practices.EnterpriseLibrary.Caching, Version=3.0.0.0, Culture=neutral, PublicKeyToken=c6897d156a3b3b19" />
     </configSections>
    
      <enterpriseLibrary.ConfigurationSource selectedSource="Local File Configuration Source">
        <sources>
          <add name="Local File Configuration Source" type="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.FileConfigurationSource, Microsoft.Practices.EnterpriseLibrary.Common, Version=3.0.0.0, Culture=neutral, PublicKeyToken=c6897d156a3b3b19"  filePath="web.config"/>
        </sources>
      </enterpriseLibrary.ConfigurationSource>
      
      <cachingConfiguration defaultCacheManager="FirstCacheManager">
        <cacheManagers>
          <add expirationPollFrequencyInSeconds="60" maximumElementsInCacheBeforeScavenging="1000" numberToRemoveWhenScavenging="10" backingStoreName="CustomWebServiceManager_1" name="FirstCacheManager" />
          <add expirationPollFrequencyInSeconds="60" maximumElementsInCacheBeforeScavenging="1000" numberToRemoveWhenScavenging="10" backingStoreName="CustomWebServiceManager_2" name="AnotherCacheManager" />
        </cacheManagers>
        <backingStores>
          <add webServiceUrl="http://localhost/CustomCachingWebservice/CachingService.asmx" partitionName="FirstTestPartition" defaultCacheDuration="7200" encryptionProviderName="" type="Microsoft.Practices.EnterpriseLibrary.Caching.BackingStoreImplementations.CustomWebServiceBackingStore, Microsoft.Practices.EnterpriseLibrary.Caching, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null" name="CustomWebServiceManager_1" />
          <add webServiceUrl="http://localhost/CustomCachingWebservice/CachingService.asmx" partitionName="AnotherPartition" defaultCacheDuration="600" encryptionProviderName="" type="Microsoft.Practices.EnterpriseLibrary.Caching.BackingStoreImplementations.CustomWebServiceBackingStore, Microsoft.Practices.EnterpriseLibrary.Caching, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null" name="CustomWebServiceManager_2" />
        </backingStores>
      </cachingConfiguration>
    Any advice would be good??

    Thanks
    Ash
    Wednesday, December 02, 2009 11:58 PM
  • I am trying to develop a Custom Functoid that will use EntLib 5 to access the DB, but this is on a box with the ESB 2 installed. I am getting the following error:

    Unable to cast object of type 'Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ConfigurationSourceSection' to type 'Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ConfigurationSourceSection'.

    So I added the appropriate secions as shown below:

    <

     

    section name="enterpriseLibrary.ConfigurationSource" type="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ConfigurationSourceSection, Microsoft.Practices.EnterpriseLibrary.Common, Version=5.0.315.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" />

    and

    <

     

    enterpriseLibrary.ConfigurationSource selectedSource="System Configuration Source">

    <sources>

    <

     

    add name="File-based Configuration Source" type="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.FileConfigurationSource, Microsoft.Practices.EnterpriseLibrary.Common, Version=5.0.315.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"

     

     

    filePath="{some path}\Web.config" />

    </

     

    sources>

    </

     

    enterpriseLibrary.ConfigurationSource>

     But I am now getting the error:

     Section or group name 'enterpriseLibrary.ConfigurationSource' is already defined. Updates to this may only occur at the configuration level where it is defined. (CF-TEST-BIZ-02 2010-04-01 08_56_37\Out\TestCustomFunctoids.dll.config line 4)

    Any ideas? I am running out of ideas...

    Thursday, April 01, 2010 8:00 AM
  • Shaeney,

    Did you ever find the solution for the error above?  I was playing around with a random C# console application that used the Enterrpise Library v5 on a machine that had ESB Toolkit on it and got the same error as you after trying the same workaround as you.

    Thanks,
    Kyle

     

    Wednesday, June 23, 2010 4:17 PM
  • Hi,

    suppose the other application in this case is BizTalk; i.e. I am already modifying BTSNTSvc.exe.config with some entlib configuration. Is ESB 2.0 also hijacking BizTalk's Entlib configuration~?

     

    thanks

    mark

     

    Thursday, October 14, 2010 3:00 PM