Discussion:
[Mono-list] Does Properties.Settings.Default.Save() work under Linux
ChrisD
2015-04-27 08:33:11 UTC
Permalink
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.
_______________________________________________
Mono-list maillist - Mono-***@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list
Edward Ned Harvey (mono)
2015-04-27 10:24:30 UTC
Permalink
Post by ChrisD
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
The first thing is, don't expect windows forms to be cross platform compatible. They're kinda sorta implemented in mono, but not good. The recommendation is to either design the business logic to be cross-platform, and then design the GUI separately for each platform (probably GTK# for linux), or use something that's intended to be cross-platform, such as Eto.Forms, or XWT.
_______________________________________________
Mono-list maillist - Mono-***@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list
Chris Down
2015-04-27 10:59:02 UTC
Permalink
Thanks for replying.
Post by Edward Ned Harvey (mono)
The first thing is, don't expect windows forms to be cross platform compatible. They're kinda sorta implemented in mono, but not good. The recommendation is to either design the business logic to be cross-platform, and then design the GUI separately for each platform (probably GTK# for linux), or use something that's intended to be cross-platform, such as Eto.Forms, or XWT.
Yes, I understand that the implementation of windows forms is incomplete and
not good, hence the question, "Does Properties.Settings.Default.Save() work
under Linux". Does the Save method work on mono?

I am just trying to port an existing application to Linux and everything works
fine except this.

Chris




_______________________________________________
Mono-list maillist - Mono-***@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list
ChrisD
2015-04-28 11:41:52 UTC
Permalink
Interestingly I can make this work by removing the appname.exe.config file.
This does not solve the problem so I will need to dig deeper. A more complex
user settings file only partially works when removing appname.exe.cofig.

Chris



-----
Chris Down
--
View this message in context: http://mono.1490590.n4.nabble.com/Does-Properties-Settings-Default-Save-work-under-Linux-tp4665828p4665838.html
Sent from the Mono - General mailing list archive at Nabble.com.
_______________________________________________
Mono-list maillist - Mono-***@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list
Justin Dearing
2015-04-28 12:24:20 UTC
Permalink
I would suggest using strace to figure out what file its trying to open. If
you can trace from that open() call up to a CLR stacktrace, you might be
able to figure out what is going on.
Post by ChrisD
Interestingly I can make this work by removing the appname.exe.config file.
This does not solve the problem so I will need to dig deeper. A more complex
user settings file only partially works when removing appname.exe.cofig.
Chris
-----
Chris Down
--
http://mono.1490590.n4.nabble.com/Does-Properties-Settings-Default-Save-work-under-Linux-tp4665828p4665838.html
Sent from the Mono - General mailing list archive at Nabble.com.
_______________________________________________
http://lists.ximian.com/mailman/listinfo/mono-list
Chris Down
2015-04-28 13:12:40 UTC
Permalink
Post by Justin Dearing
I would suggest using strace to figure out what file its trying to open. If
you can trace from that open() call up to a CLR stacktrace, you might be
able to figure out what is going on.
Thanks Justin, I will give it a try

Chris
_______________________________________________
Mono-list maillist - Mono-***@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list

Continue reading on narkive:
Loading...