Alright, so I know about the Settings.Properties.Default.* Stuff, but thats not what im trying to use.. I’m trying to develop my own class, ill show you:
public sealed class SettingsHolder<T>
{
public SettingsHolder(){}
public T Setting
{
get{ /*return setting*/ }
set( /*store setting*/ }
}
}
so then i could compile that to a dll, and reference it in an application, and do something like this
SettingsHolder<string> stringHolder = new SettingsHolder<string>();
stringHolder.Setting = "hello world";
and on next application launch
string welcome = stringHolder.Setting;
and welcome should = “hello world”.. is this at all possible? i had origannally tried to disect the actual properties.settings class, but with no luck
The .NET/VS settings framework already does exactly what you indicate that you’re trying to do, without the clumsy runtime casts and generic classes. Absent a very compelling reason not to use it, that is what you should use. It already handles persisted user-level settings.
If for some reason you absolutely cannot use that, either store the settings directly in a file somewhere in the user’s AppData, or use Isolated Storage. You will have to write your own persistence model for it.
If an application could rewrite its own executable code on disk, it would raise all sorts of thorny questions about security and reliability. Besides, security restrictions on Vista and Windows 7 would prevent it from functioning correctly anyway – unless it’s a ClickOnce app, it’s probably installed in a program folder (i.e. Program Files), and you’d need a user with administrative privileges to elevate the process in order to make it work.