How do I invoke my custom settings provider?
Posted
by joebeazelman
on Stack Overflow
See other posts from Stack Overflow
or by joebeazelman
Published on 2010-05-01T01:56:39Z
Indexed on
2010/05/01
2:07 UTC
Read the original article
Hit count: 404
I need to specify a different location for my settings file. After many long hours of searching, I found out that I have to write my own SettingsProvider. I succeeded in creating one which allows me to specify a path for settings file via its constructor. Programatically, I can contruct it like this:
var mycustomprovider = new CustomSettingsProvider(path);
The problem I am having is that there's no way to invoke my custom provider. I can decorate the VS 2008 generated setting file with the following attribute:
[SettingsProvider(typeof(CustomSettingProviders.CustomSettingsProvider))]
internal sealed partial class Settings {
}
However, the attribute doesn't allow me to construct the object with a path. Also, I want to be able to set the SettingsProvider programmatically so that I can pass in any path I want at runtime and save my settings. The examples I've seen on the net have never mentioned how to use a invoke a SettingsProvider programmatically.
© Stack Overflow or respective owner