Enterprise Library (DAAB)-Using a custom config file

Topics: Data Access Application Block
Apr 20, 2007 at 3:25 PM
Hello there! I'm running into trouble with DAAB because of this.
I have an application where I need to specify where the configuration to be used by Enterprise Library is located. This is because we're accessing a COM exposed custom object using DAAB.

I'm using the following code:

Microsoft.Practices.EnterpriseLibrary.Common.Configuration.FileConfigurationSource configFile =
new Microsoft.Practices.EnterpriseLibrary.Common.Configuration.FileConfigurationSource(


Database db = DatabaseFactory.CreateDatabase();

All goes well, it compiles. But...When creating the database, the settings object is null and an exception is thrown because of that. the configFile object has all the info of the config file I've passed, but even so the DAAB doesn't seem to like me and work :(

Can you folks help me? I've already busted my head off on the internet searching for a way to put this to work...
Apr 20, 2007 at 5:26 PM
The correct way to do this is:
FileConfigurationSource configSource = new FileConfigurationSource("myconfigfile.config");
DatabaseProviderFactory factory = new DatabaseProviderFactory(configSource);
Database db = factory.Create();

Apr 20, 2007 at 8:50 PM

It did solve my problem. :)