title: Custom ConfigurationSection: CallbackValidator called with empty string
body: <p>I am writing a custom configuration section, and I would like to validate a configuration property with a callback, like in this example:  </p>
  
  <pre><code>using System;
  using System.Configuration;
  
  class CustomSection : ConfigurationSection {
  
      [ConfigurationProperty("stringValue", IsRequired = false)]
      [CallbackValidator(Type = typeof(CustomSection), CallbackMethodName = "ValidateString")]
      public string StringValue {
          get { return (string)this["stringValue"]; }
          set { this["stringValue"] = value; }
      }
  
      public static void ValidateString(object value) {
          if (string.IsNullOrEmpty((string)value)) {
              throw new ArgumentException("string must not be empty.");
          }
      }
  }
  
  class Program {
      static void Main(string[] args) {
          CustomSection cfg = (CustomSection)ConfigurationManager.GetSection("customSection");
          Console.WriteLine(cfg.StringValue);
      }
  }
  </code></pre>
  
  <p>And my App.config file looks like this:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
  &lt;configuration&gt;
    &lt;configSections&gt;
      &lt;section name="customSection" type="CustomSection, config-section"/&gt;
    &lt;/configSections&gt;
    &lt;customSection stringValue="lorem ipsum"/&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>My problem is that when the <code>ValidateString</code> function is called, the <code>value</code> parameter is always an empty string, and therefore the validation fails. If i just remove the validator, the string value is correctly initialized to the value in the configuration file.  </p>
  
  <p>What am I missing?</p>
  
  <p><strong>EDIT</strong> I discovered that actually the validation function is being called twice: the first time with the default value of the property, which is an empty string if nothing is specified, the second time with the real value read from the configuration file. Is there a way to modify this behavior?</p>