Bug in Composite.Configuration.FileConfigurationSource.cs

Topics: Enterprise Library Core
Jul 29, 2010 at 3:45 PM

How human can write such code?:

  private static string GetRootedCurrentConfigurationFile(string configurationFile)
        {
            if (string.IsNullOrEmpty(configurationFile))
                throw new ArgumentException(Resources.ExceptionStringNullOrEmpty, "configurationFile");

            if (!File.Exists(configurationFile))
            {
                throw new FileNotFoundException(
                    string.Format(
                        CultureInfo.CurrentCulture,
                        Resources.ExceptionConfigurationLoadFileNotFound,
                        configurationFile));
            }

            return
                Path.IsPathRooted(configurationFile)
                    ? configurationFile
                    : Path.Combine(AppDomain.CurrentDomain.BaseDirectory, configurationFile);
        }

Problem is here:

   if (!File.Exists(configurationFile))
            {
                throw new FileNotFoundException(
                    string.Format(
                        CultureInfo.CurrentCulture,
                        Resources.ExceptionConfigurationLoadFileNotFound,
                        configurationFile));
            }

If we give a path part we always get exception!

 

Jul 30, 2010 at 6:39 AM

This was logged in the Issue Tracker, vote for it here.  The workaround would be to create your version of FileConfigurationSource (this is the preferred approach) or modify the source code.

 

Sarah Urmeneta
Global Technology & Solutions
Avanade, Inc.
entlib.support@Avanade.com