about Using Alternate Configuration Sources

Topics: Data Access Application Block, Enterprise Library Core
May 22, 2007 at 9:41 AM
I change the configuration file to use another XML file to get the connection string(using <enterpriseLibrary.ConfigurationSource selectedSource=).It seems work well.
Then, after I move that connection string to the application configuration file, there is an error said that "The requested database pubsql is not defined in configuration " .So , seems that
the entlib did not "try to read the configuration section from the System Configuration Source" after it can not find the configuration section from the configured source location.
I just wonder whether I misunderstanding these words writtend in the help file of Entlib3.0,"The core configuration classes that support reading configuration information first try to read the requested configuration section from the configured source location. If the configuration section is not found, the core classes try to read the configuration section from the System Configuration Source."
Help me.
thanks a lot!

May 22, 2007 at 4:56 PM
You are misreading the passage in the documentation. The text is:

"You can use other sources—such as a SQL database—to derive your configuration information. The application configuration file contains a configuration section that defines the configuration source. If this section is missing, the application configuration file is used as the configuration source."

It means that if you haven't specified a separate configuration file to hold EntLib Settings, it defaults to the app.config or web.config.

This doesn't mean that it will look two different places for configuration information.




David Hayden
Microsoft MVP C#
May 23, 2007 at 3:01 AM
David,thanks so much.I now understand.
but is there a way for us to use Entlib like this?---Several applications using Entlib,they find the data access configuration setting from the app.config or web.config ,while find logging configuration setting or other Entlib configuration settings from the same special XML file ? It meane that we do not want to save the whole Entlib settings in one file,but different file for different applicaiotn block section.Can we do it?
May 23, 2007 at 3:57 AM
I notice that we can implement these by using the FileConfigurationSource in code,but this is not a good way---we want config change not code change.
An maybe the "configSource" is a good way,but I found that I can not put different section infos in one file and seems that the external file must be stay in the same directory or subdirectory with the web.config.
Anyone has ideas?