title: C# Application Settings not saving using custom class
body: <p>Here's the class im trying to store</p>
  
  <pre><code> [Serializable]
  [XmlRoot(ElementName = "Database", IsNullable = false, Namespace = "http://somesite.com")]
  
  class Database
  {
      [XmlAttribute(AttributeName = "Name")]   
      public string Name { get; set; }
  
      [XmlAttribute(AttributeName = "Provider")]
      public DatabaseProvider Provider { get; set; }
  
      [XmlAttribute(AttributeName = "Driver")]
      public string Driver { get; set; }
  
      [XmlElement("DatabaseEntry")]
      public List&lt;DatabaseEntry&gt; SavedEntries { get; set; }
  
      public Database()
      {
          SavedEntries = new List&lt;DatabaseEntry&gt;();
      }
  
      public Database(string type, string provider, string driver)
      {
  
          Name = type;
          Driver = driver;
          Provider = DatabaseProvider.SqlClient;
  
          Provider = SetProvider(provider);
          SavedEntries = new List&lt;DatabaseEntry&gt;();
      }
  
      private DatabaseProvider SetProvider(string provider)
      {
          switch (provider)
          {
              case "OleDb":
                  return DatabaseProvider.OleDb;
              case "SqlClient":
                  return DatabaseProvider.SqlClient;
              default:
                  return DatabaseProvider.SqlClient;
          }
      }
  }
  
  [Serializable]
  [XmlRoot(ElementName = "DatabaseEntry", IsNullable = false, Namespace = "http://somesite.com")]
  
  class DatabaseEntry
  
  {
      [XmlAttribute(AttributeName = "Name")]
      public string Name { get; set; }
  
      [XmlAttribute(AttributeName = "ConnectionString")]
      public string ConnectionString { get; set; }
  
      [XmlAttribute(AttributeName = "DsnString")]
      public string DsnString { get; set; }
  
      public DatabaseEntry()
      { }
  }
  </code></pre>
  
  <p>Database is the parent class that I'm trying store, anyone see anything wrong?  When I instantiate the class and save it, nothing gets saved.  What gives?</p>
  
  <p>EDIT! The code that is being used to save:</p>
  
  <pre><code>if (Settings.Default.SqlDatabase == null) 
     { 
        Settings.Default.SqlDatabase = CreateNewDatabase();
        Settings.Default.Save();
     }
  
  private Database CreateNewDatabase()
  {
      Database data = new Database("SQL Server", "SqlClient", "SQL Native Client");
      data.SavedEntries.Add(new DatabaseEntry()
      {
          Name = "Default",
          ConnectionString = @"Hello1",
          DsnString = @"Hello2"
      });
      return data;
  }
  </code></pre>
  
  <p>I'm simply just trying to store an instance of a Database class into the AppSettings</p>