How to provide relative path for "File Configuration Source"?

Topics: Logging Application Block
Dec 1, 2009 at 10:05 AM

My App.config - contains:



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


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


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

        filePath="D:\CustomLogging.config" />







CustomLogging.config file consists of my Logging configuration. The application is working fine with the absolute path. EL is able to read LAB configuration from the custom file. But I want to give the relative path of the application.

If we change filePath="D:\CustomLogging.config" /> to filePath="CustomLogging.config" /> or filePath="..\..\CustomLogging.config" /> it looks for the file in C:\Program Files\Microsoft Visual Studio 9.0\...

Rather my CustomLogging.config file is present in the same directory where the app.config lies.

Is there a way I can provide relative path for filePath attribute.

Can we give path programmatically. I Tried initializing the Configuration.FileConfigurationSource with the CustomLogging.config file. But could not find a way to give it to the EL configuration.

It would be helpful if anyone gives me a few pointers or code snippets in case of programmatic intialization of File Configuration Source.



Abhijeet Inamdar.

Dec 1, 2009 at 11:37 AM


I tried something like you've decribed and its working fine for me. For the filePath like this(filePath="CustomLogging.config")  the config file is the same level as my executable. I can send you my sample solution.

Valiant Dudan
Global Technology and Solutions
Avanade, Inc.

Dec 1, 2009 at 11:48 AM

That would be great.



Dec 1, 2009 at 11:49 AM

Where should I send it?

Dec 1, 2009 at 5:07 PM

Other readers - no spam please.


BTW I'm using VSTS Unit Testing to test the Logging class. This is the place it is creating a problem.

I might work for application. I would like to have a look at the code.




Dec 2, 2009 at 7:34 AM

Abhijeet, we're unable to send mail with .zip attachments to gmail.  Please provide another email address.  You need not post it here, just send us an email in