[Mono-list] Problem retrieving application settings using ApplicationSettingsBase

greyseal96 greyseal96 at gmail.com
Sun Jan 6 07:56:48 UTC 2013


Hello,

First things first, I'm using MonoDevelop 2.8.8.4 targeting Mono 2.10.5.  My
development machine is running Fedora 16.  

I'm trying to get a class derived from ApplicationSettingsBase to correctly
retrieve the application settings stored in an app.config file.  I have done
this before in .NET a few times so I'm pretty sure that I'm familiar with
how it works and how to set up the app.config file.  Having said that,
though, it's always possible that I've missed something or messed something
up. :)

I'm trying to access a couple of properties which are marked with the
[ApplicationScopedSetting()] attribute but the values aren't being retrieved
from the app.config file.  I don't have  a default value set on these
properties either so when I try to retrieve the values from the settings
file, the properties (they are string type) are null.  I have a couple other
properties in my class which are marked with the [UserScopedSetting()]
attribute and I am able to save and retrieve these settings without any
problems; it's only the application settings that aren't working for me.

I have been looking all over and googleing to try to figure out why this
might not be working but I haven't been able to find anything.  Is this
working in Mono 2.10.5?

For reference, here is a copy of my app.config file:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
	<configSections>
		<sectionGroup name="applicationSettings"
type="System.Configuration.ApplicationSettingsGroup, System,
Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
			<section name="mySettings"
type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0,
Culture= neutral, PublicKeyToken=b77a5c561934e089" />
		</sectionGroup>
	</configSections>
	<applicationSettings>
		<mySettings>
			<setting name="AcctID" serializeAs="String">
				<value>555666777A</value>
			</setting>
			<setting name="AccKey" serializeAs="String">
				<value>AccKeyHere</value>
			</setting>
		</mySettings>
	</applicationSettings>	
	
	<appSettings>
		<add key="StringSetting1" value="some value"/>
		<add key="StringSetting2" value="some other value"/>
	</appSettings>	
</configuration>

Here's some of the code for my settings class:
	[SettingsGroupName("mySettings")]
	public class myAppSettings : ApplicationSettingsBase
	{
		[ApplicationScopedSetting()]
		public string AcctID
		{
			get
			{
				return (String)this["AcctID"];	
			}
		}
		
		[ApplicationScopedSetting()]
		public string AccKey
		{
			get
			{
				return (String)this["AWSAccKey"];
			}
		}
		//This is working fine; its setting is saved and retrieved correctly from
the user.config file.
		[UserScopedSetting()]
		public string TestSaveString
		{
			get
			{
				return (String)this["TestSaveString"];
			}
			
			set
			{
				this["TestSaveString"] = value;
			}
		}
	}

Any help in understanding how this works in Mono would be greatly
appreciated.  Thanks for any help that you can give.

Regards,
John



--
View this message in context: http://mono.1490590.n4.nabble.com/Problem-retrieving-application-settings-using-ApplicationSettingsBase-tp4658003.html
Sent from the Mono - General mailing list archive at Nabble.com.


More information about the Mono-list mailing list