2

Using Visual Studio generated Settings file, when I input only spaces they are converted to a line break.

I think that's because the Settings file content is synchronized to app.config and as the IDE has XML auto formatting enabled it converts:

<setting name="Separator" serializeAs="String">
    <value> </value>
</setting>

to

<setting name="Separator" serializeAs="String">
    <value>
    </value>
</setting>

automatically.

How to fix this without disabling XML auto formatting?

I tried &nbsp; without success.

Jader Dias
  • 88,211
  • 155
  • 421
  • 625
  • 1
    It is strange indeed. The only thing I found is: create the setting, edit the app.config file:   (which is xml for non bracking space) Open the settings file, it will warn that it is changing the value, press ok. But, the setting when used in code will give as string So, not a complete answer... Marcel – MarcelDevG Dec 16 '10 at 11:10
  • I reported this as a bug to MS Connect: https://connect.microsoft.com/VisualStudio/feedback/details/632147/settings-designer-and-app-config-doesnt-store-spaces-as-string-simultaneously – Jader Dias Dec 17 '10 at 11:33
  • 1
    I've posted it as an answer and I upvoted your feedback on connect. – MarcelDevG Dec 22 '10 at 17:46

2 Answers2

1

You can edit the app.config file manually to remove the CR/LF characters in between the tags. However, my tests (in VS2008) always resulted in the CR/LF characters being reinserted anytime you open the properties window for the project in VS.

Perhaps the best solution is to use a custom settings file that lives outside of the standard project settings used by VS.

pmartin
  • 2,731
  • 1
  • 25
  • 30
1

It is strange indeed. The only thing I found is: create the setting, edit the app.config file: <Value>&#160;</Value> (which is xml for non bracking space) Open the settings file, it will warn that it is changing the value, press ok. But, the setting when used in code will give &#32; as string So, not a complete answer...

Marcel

MarcelDevG
  • 1,377
  • 10
  • 10