How to set some configuration information read from another application?

Topics: General discussion
May 6, 2009 at 9:22 PM

Hello, I use EntLib 2.0, an by policy of the company I work, all applications must obtain certain information such as configuration connection string, SMTP server mail etc, from a specific configuration files, which can only read the entries for our application using a class created specifically for this task.
The problem is that some configuration data, such as connection-string for the various blocks should be loaded into the execution mode.
As I can not find how to do one of the problems we encounter is if for example I have a "Database Trace Listener" where there is an attribute "DatabaseInstance" where I choose one of the database instance, but could not specify the connection string directly in the web.config or mode of execution can not select this instance.
Something similar happens if I have an "Email Trace Listener", where do I get SMTP Server attribute of another application.

Is there any way to change values in run-time mode, or some configuration parameters you can specify that the value of a given parameter will be loaded by a method of a class?

Any Example?

Hope has understood the problem and sorry for my English.

Thank you very much

May 7, 2009 at 6:34 AM

In the case of your Email Trace Listener, you can change the values of the properties of that listener. like this:

            ExeConfigurationFileMap exeFileMap = new ExeConfigurationFileMap();

            exeFileMap.ExeConfigFilename = "Filenameoftheconfig";

            Configuration configuration = ConfigurationManager.OpenMappedExeConfiguration(exeFileMap, ConfigurationUserLevel.None);

            LoggingSettings loggingSettings = (LoggingSettings)configuration.Sections.Get(LoggingSettings.SectionName);

            EmailTraceListenerData emailData = (EmailTraceListenerData)loggingSettings.TraceListeners.Get("Email TraceListener");

            emailData.SubjectLineStarter = "Starter";


I'm not that sure if the same could be apply and will work in the database tracelistener, perhaps you could try that. Also, there is an option for you to use the Logging Application Block within your application without using configuration files. Please see this:

Valiant Dudan
Global Technology and Solutions
Avanade, Inc.
Jun 11, 2009 at 4:54 AM

Please see my EntLibWrapper class at the following link:

I think this will help you.


Raja Lakshman