title: Create custom section in config file
body: <p>I am trying to create custom section in app.config file </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
  &lt;configuration&gt;
    &lt;configSections&gt;
      &lt;section name="BlogSettings" type="ConsoleApplication1.BlogSettings,   
        ConsoleApplication1" /&gt;
    &lt;/configSections&gt;
    &lt;BlogSettings
      Price="10"
      title="BLACKswastik" /&gt;
  &lt;/configuration&gt; 
  </code></pre>
  
  <p>C# code :</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.Configuration;
  
  namespace ConsoleApplication1
  {
      class Program
      {
          static void Main(string[] args)
          {
              string title = BlogSettings.Settings.Title;
  
              Console.WriteLine(title);
              Console.ReadKey();
          }
      }
  
      public class BlogSettings : ConfigurationSection
      {
          private static BlogSettings settings
            = ConfigurationManager.GetSection("BlogSettings") as BlogSettings;
  
          public static BlogSettings Settings
          {
              get
              {
                  return settings;
              }
          }
  
          [ConfigurationProperty("Price"
            , DefaultValue = 20
            , IsRequired = false)]
          [IntegerValidator(MinValue = 1
            , MaxValue = 100)]
          public int Price
          {
              get { return (int)this["Price"]; }
              set { this["Price"] = value; }
          }
  
  
          [ConfigurationProperty("title"
            , IsRequired = true)]
          [StringValidator(InvalidCharacters = "  ~!@#$%^&amp;*()[]{}/;’\"|\\"
            , MinLength = 1
            , MaxLength = 256)]
          public string Title
          {
              get { return (string)this["title"]; }
              set { this["title"] = value; }
          }
      }
  }
  </code></pre>
  
  <p>but when I run this code I am getting this error:</p>
  
  <blockquote>
    <p><em>The type initializer for 'ConsoleApplication1.BlogSettings' threw an
    exception.</em></p>
  </blockquote>
  
  <p>Please suggest me whats wrong I am doing.</p>