How to make designer generated .Net application settings portable

Posted by Ville Koskinen on Stack Overflow See other posts from Stack Overflow or by Ville Koskinen
Published on 2009-09-05T06:15:09Z Indexed on 2010/04/05 16:03 UTC
Read the original article Hit count: 369

Filed under:
|
|
|

Hello,

I've been looking at modifying the source of the Doppler podcast aggregator with the goal of being able to run the program directly from my mp3 player.

Doppler stores application settings using a Visual Studio designer generated Settings class, which by default serializes user settings to the user's home directory. I'd like to change this so that all settings would be stored in the same directory as the exe.

It seems that this would be possible by creating a custom provider class which inherits the SettingsProvider class. Has anyone created such a provider and would like to share code?

Update: I was able to get a custom settings provider nearly working by using this MSDN sample, i.e. with simple inheritance. I was initially confused as Windows Forms designer stopped working until I did this trick suggested at Codeproject:

internal sealed partial class Settings
{
    private MySettingsProvider settingsprovider = new MySettingsProvider();

    public Settings()
    {
        foreach (SettingsProperty property in this.Properties)
        {
            property.Provider = settingsprovider;
        }
    ...

The program still starts with window size 0;0 though.

Anyone with any insight to this?

  • Why the need to assing the provider in runtime---instead of using attributes as suggested by MSDN?
  • Why the changes in how the default settings are passed to the application with the default settings provider vs. the custom one?

© Stack Overflow or respective owner

Related posts about .NET

Related posts about c#