Relative File Configuration Source

Topics: Enterprise Library Core
Sep 3, 2010 at 11:03 PM

I have searched on this discussion board and found a similar topic though it didn't answer my question.

I upgraded one of my projects to use entlib 5.0 and since then, I've been having issues using a file configuration source.

I have two projects.  One is a forms app and is working fine without change.

The other is a windows service and has an identical configuration:

Here is the main config snippet

    <section name="enterpriseLibrary.ConfigurationSource" type="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.ConfigurationSourceSection, Microsoft.Practices.EnterpriseLibrary.Common, Version=5.0.414.0, 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=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        filePath="EntLib.config" />
      <add name="System Configuration Source" type="Microsoft.Practices.EnterpriseLibrary.Common.Configuration.SystemConfigurationSource, Microsoft.Practices.EnterpriseLibrary.Common, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />

In my external config I have PIAB, logging, and database configs.  The SECOND I hit something that  would read the config I get FileNotFoundException.  I dug a little deeper using Process Monitor and found that it's looking in C:\Windows\System32\EntLib.config for the config.  This is perplexing.  I tried ./EntLib.config and .\EntLib.config.  Neither work.  I then put an absolute path and everything worked properly.

I don't have this problem when using a forms app that has the EXACT same config.

I was thinking that it might have something to do with the process account that's running the service.  Though, the relative path should always be based on where the application is running and I'm 100% positive the config is in my bin\Debug folder and the service is pointing at that directory.

Was there a change in EntLib 5 that I'm not aware of?  I read the change docs and didn't see anything about this.  Everything was working fine (and is still working fine in production) before I moved over to the new version. 

Any help would be appreciated.  Thank you.

Sep 3, 2010 at 11:10 PM

I should mention that I have read this


I am not running under the system account.

Sep 6, 2010 at 4:04 AM

I think that is the issue you're encountering.  If you don't want to modify the source code and rebuild entlib just to see if that's what's really causing the issue, I recommend extending entlib by creating a new fileconfiguration source which just basically copies the source code of the existing entlib FileConfigurationSource but also contains the necessary modification.  Sample code and how to use it was discussed in this thread.


Sarah Urmeneta
Global Technology and Solutions
Avanade, Inc.