chateaur chateaur -4 years ago 144 Question

Why Visual Studio settings are all serialized as String?

I am using Visual Studio express 2010 and I have a Windows Form app which uses Application Settings.

I've set few settings with Visual Studio IDE. I specified types like Integer or Boolean. The variables are typed well since I have option Strict On and I can bound typed variable with the matching setting.

My question is in the resulting AppName.exe.config : all settings in it are tagged as String. Why it's not serialized as the right type ?

The example below is an integer in my code :

<setting name="timeout_reviewed" serializeAs="String">

Answer Source

Firstly, keep in mind that the settings file is text based, so: some kind of string conversion is not surprising. The most convenient way to store the integer value 10000 in text is the string "10000".

But: there are four options:

  • string
  • xml
  • binary
  • custom

Now; this data isn't xml, so we can ignore the xml option. And the binary and custom options require lots of extra work from you; so - string is the most pragmatic and useful implementation that solves 98% of common usage while also being really easy to maintain via any text editor. For exotic scenarios you can still do your own thing, but you need to work harder at it.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download