[Mono-list] Does Properties.Settings.Default.Save() work under Linux

ChrisD chris.down at alcor.co.uk
Mon Apr 27 08:33:11 UTC 2015


I am having problems saving user settings under Linux. Everything works fine
if I run under Windows.

On Linux, I copy the files appname.exe and appname-exe.config to appname
directory and execute using

mono appname.exe.

As a simple example: I have created a Winform with a TextBox as use the
following code to test saving the user settings:

using System;
using System.Windows.Forms;

namespace SettingsSaveTest
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            textBox1.Text = Properties.Settings.Default.TestString1;
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {
            Properties.Settings.Default.TestString1 = textBox1.Text;
            Properties.Settings.Default.Save ();
        }
    }
}


I have a appname.settimgs file under Properties as follows:

<?xmlversion='1.0'encoding='utf-8'?>
<SettingsFilexmlns
="http://schemas.microsoft.com/VisualStudio/2004/01/settings"CurrentProfile
="(Default)"GeneratedClassNamespace
="SettingsSaveTest.Properties"GeneratedClassName ="Settings">
  <Profiles/>
  <Settings>
    <SettingName ="TestString1"Type="System.String"Scope ="User">
    <ValueProfile ="(Default)">Test1</Value>
   </Setting>
   <Setting Name ="TestString2"Type ="System.String"Scope ="User">
     <ValueProfile ="(Default)">Test1</Value>
    </Setting>
  </Settings>
</SettingsFile> 


When I change the text in the test box and quit the program the
./local/share/appname/user.config file is created and contains just the
following xml:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <userSettings />
</configuration>

Whereas under Window user.config contains:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <userSettings>
        <SettingsSaveTest.Properties.Settings>
            <setting name="TestString1" serializeAs="String">
                <value>Test123</value>
            </setting>
        </SettingsSaveTest.Properties.Settings>
    </userSettings>
</configuration>


Any ideas what I may be doing wrong? 



-----
Chris Down
--
View this message in context: http://mono.1490590.n4.nabble.com/Does-Properties-Settings-Default-Save-work-under-Linux-tp4665828.html
Sent from the Mono - General mailing list archive at Nabble.com.


More information about the Mono-list mailing list