Adding reference to ENterprise Library DLL in a Class library Project

Topics: Data Access Application Block
Apr 29, 2009 at 5:26 AM
Edited Apr 29, 2009 at 8:47 PM

I have a class Library Project in C# .NET . In That I have added referenece to the Ent Lib 3.1 Data ACcess APplication DLL's . I have added an app.config to the CLass Library project and Using the entlibraryconfig.exe I have created the connection string in APP.COnfig .
I now need to access the app.config from the class library for creating the Db:
db = DatabaseFactory.CreateDatabase("conn");
However since it is a class library project, it cannot read from the APP.config file.

I need a Class library because I need to reference this DLL from Biztalk application.

Please suggest what are my options for creating the connection string to get accessed from the class library project.

Thank you.
Apr 29, 2009 at 8:36 AM

One option for you is to put the DAAB information in the application that will host the class library which is your biztalk application. Also, you can try to use the IConfigurationSource to read your app.config, you can learn more about IConfigurationSource here: .

Here is a code snippet for IConfigurationSource:


string configPath = GetConfigPath();
IConfigurationSource source = new FileConfigurationSource(configPath);
DatabaseProviderFactory providerFactory = new DatabaseProviderFactory(source);
Database db = providerFactory.Create("MyDatabase");

Valiant Dudan
Global Technology and Solutions
Avanade, Inc.