[Mono-list] Problem retrieving application settings using ApplicationSettingsBase
Daniel Lo Nigro
lists at dan.cx
Sun Jan 6 09:53:23 UTC 2013
For what it's worth, I've never used ApplicationSettingsBase but I'm using
a custom ConfigurationSection with an ASP.NET site and that's working fine
for me under Mono 3.0.2. I'm not sure if ConfigurationSection is something
specific to ASP.NET or whether it can be used in desktop apps as well.
Here's mine as an example:
The section:
https://github.com/Daniel15/Website/blob/master/Daniel15.Web/Infrastructure/SiteConfiguration.cs
The web.config:
https://github.com/Daniel15/Website/blob/master/Daniel15.Web/Web.config#L17
This blog post has some more information on this:
http://haacked.com/archive/2007/03/11/custom-configuration-sections-in-3-easy-steps.aspx
On Sun, Jan 6, 2013 at 6:56 PM, greyseal96 <greyseal96 at gmail.com> wrote:
> 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.
> _______________________________________________
> Mono-list maillist - Mono-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ximian.com/pipermail/mono-list/attachments/20130106/ed2b6f04/attachment.html>
More information about the Mono-list
mailing list