Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. UserSettings in VS 2005, how they serialize?

UserSettings in VS 2005, how they serialize?

Scheduled Pinned Locked Moved C#
csharpcssvisual-studiowinformsxml
2 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    TigerNinja_
    wrote on last edited by
    #1

    In VS 2005 (Winforms Project) you have the following class supplied for you : class Settings : global::System.Configuration.ApplicationSettingsBase { This class is actually created by the designer. With the designer you can define your settings (Expand properites folder, and select Settings file). It is nice grid with drop downs that allow you to easily add new settings. The grid columns are basically "Name", "Type", "Scope", "Default Value". Now I haven't had any problems, until I wanted to use a different type that was not in the drop down for the "Type" column. Documentation says this relating to serialization (supplied by the LocalFileSettingsProvider class):

    Serializes the property to disk. It first attempts to call the ConvertToString or ConvertFromString on the type's associated TypeConverter. If this does not succeed, it uses XML serialization instead.

    So according to this I would think I could use a setting with the type being set to Hashtable, no? So when I add a setting and set type to Hashtable, I then investigate the xml where it gets persisted, and find a placeholder for the hashtable, with an attribute on the xml node stating "serializeas= xml", but NO values are saved. Doesn't a Hashtable serialize to Xml without any customizations? I can not find any examples of code where people use Hashtable as a user setting, so any help or reference is greatly appreciated.

    R.Bischoff

    Tengas un buen dia

    T 1 Reply Last reply
    0
    • T TigerNinja_

      In VS 2005 (Winforms Project) you have the following class supplied for you : class Settings : global::System.Configuration.ApplicationSettingsBase { This class is actually created by the designer. With the designer you can define your settings (Expand properites folder, and select Settings file). It is nice grid with drop downs that allow you to easily add new settings. The grid columns are basically "Name", "Type", "Scope", "Default Value". Now I haven't had any problems, until I wanted to use a different type that was not in the drop down for the "Type" column. Documentation says this relating to serialization (supplied by the LocalFileSettingsProvider class):

      Serializes the property to disk. It first attempts to call the ConvertToString or ConvertFromString on the type's associated TypeConverter. If this does not succeed, it uses XML serialization instead.

      So according to this I would think I could use a setting with the type being set to Hashtable, no? So when I add a setting and set type to Hashtable, I then investigate the xml where it gets persisted, and find a placeholder for the hashtable, with an attribute on the xml node stating "serializeas= xml", but NO values are saved. Doesn't a Hashtable serialize to Xml without any customizations? I can not find any examples of code where people use Hashtable as a user setting, so any help or reference is greatly appreciated.

      R.Bischoff

      Tengas un buen dia

      T Offline
      T Offline
      TigerNinja_
      wrote on last edited by
      #2

      Follow up: I have gotten it to work when serializing as binary. I placed the following attribute on my setting of type Hashtable: [global::System.Configuration.SettingsSerializeAs(System.Configuration.SettingsSerializeAs.Binary)] I guess Hashtables can serialize out of the box in binary mode, but not xml.

      R.Bischoff

      Tengas un buen dia

      -- modified at 11:28 Thursday 23rd March, 2006

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups