How to make a custom application setting?I mean i want to serialize Hashtable but AFAIK that can't be done in Settings.Designer.cs and therefore must be done in separate class.But i don't know how to access the setting in that new class from other classes where i need to use the setting.The default application settings are accessed like this Properties.Settings.Default.... but what about the custom settings?Here is the new setting class...

using System;
using System.Configuration;
using System.Collections.Generic;

namespace Properties
{
internal sealed class servers : ApplicationSettingsBase
{
[ApplicationScopedSetting()]
[SettingsSerializeAs(System.Configuration.SettingsSerializeAs.Binary)]
[DefaultSettingValue(@"")]
public System.Collections.Hashtable ServersHashtable
{
get
{
return ((System.Collections.Hashtable)this["ServersHashtable"]);
}
set
{
this["ServersHashtable"] = (System.Collections.Hashtable)value;
}
}
}
}

Recommended Answers

All 3 Replies

servers.Default.ServersHashtable = new HashTable();

Yeah,but the ServersHashtable is not visible,that's the problem.By the way,i don't want to make new hashtable every time because i just want to save the setting to the disk and when start application to load the setting.Just like the default application settings,that's it.

I don't mean = new HashTable() I mean how to see it.
I tried it it works with me, check it again and make sure all classes call this server class have the same namespace or change the access modifier of the server class to public.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.