locked
user.scope settings path changed after upgrade RRS feed

  • Question

  • Hi I have develop a small app in c# (.net 4.0) that uses the LocalFileSettingsProvider Class to save and load settings for the user. But after the last upgrade last night I have notice that the url path

    <Profile Directory>\<Company Name>\<App Name>_<Evidence Type>_<Evidence Hash>\<Version>\user.config

    changes after I run the upgraded application. What I believe is being changed is the "<Evidence Type>_<Evidence Hash>"

    part of the path. Since the last upgrade I have only change a few lines of code to fix a minor bug in my application and the application version. Everything else look the same so I am a little bit in the dark here. I have also tried to revert to an older version of the app and re-commit the changes again but the result was the same.

    Does anyone have any clue why the above path is now being changed and causes the user settings not to get upgraded? Is the above behavior normal for the LocalFileSettingsProvider Class?

    Under what circumstances does the above path get changed?

    Any help is appreciated!

    Regards



    Sunday, January 4, 2015 12:12 PM

Answers

  • Hi Fred and thanks for the lengthy respond. Please note that I did not change the path of the executable

    "It seems that you changed the executable application path, then it should be that the Evidence Hash is changed, because this values is affected by two things, for a details...,"

    I only change (temporarily) the path of the developing directory.

    Anyway I have continue and create my own SettingsProvider and set up my own path for settings. It took me a while since I had to make changes in both my settings and my application but I think that eventually I have fix all the bugs that resulted from the change.

    I will ask from my users to manually set their settings again after upgrading to the new version of my software. I know it is not perfect but at least I do not have to worry that the path will again change in the future since now I am setting it explicitly. I wished that there was a way to change the settings path in the default settings provider.

    Thanks for the help.

    • Marked as answer by Fred Bao Friday, January 16, 2015 4:43 AM
    Monday, January 12, 2015 8:29 PM

All replies

  • Hello phanospa,

    >> Does anyone have any clue why the above path is now being changed and causes the user settings not to get upgraded? Is the above behavior normal for the LocalFileSettingsProvider Class?

    Have you made your assembly to be a stronge singed one? If it is, as far as I know, for such assemblies, when the dll(an .exe is also a dll) is changed, the <App Name>_<Evidence Type>_<Evidence Hash> would also change since this value is information derived from the app domain evidence to provide proper app domain and assembly isolation. Please check if you are under this scenario.

    Regards.

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, January 5, 2015 3:37 AM
  • Hello Fred,

    no it is not a strong one. I have created a couple of upgraded versions during the last month and all work fine, the .Upgrade function upgraded the user settings just fine to the new versions. Unitl of course the last upgrade when the path change and the previous settings are not found and the app starts up with the default ones.

    I am confused. If the path changes how can someone hope to upgrade the settings and not loose them when an upgrade version is available?

    Monday, January 5, 2015 10:33 AM
  • Hello phanospa,

    >> Unitl of course the last upgrade when the path change and the previous settings are not found and the app starts up with the default ones.

    This really sounds strange, since we cannot reproduce this issue, could you please share some code about how you save/upgrade your setting?

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, January 6, 2015 10:11 AM
  • Hi Fred,

    I define my settings object as follows

     public class ApplicationSettings : ApplicationSettingsBase
        {
            [UserScopedSetting()]
            [DefaultSettingValue("")]
            public DateTime UpTimeSincePaused
            {
                get
                {
                    return ((DateTime)this["UpTimeSincePaused"]);
                }
                set
                {
                    this["UpTimeSincePaused"] = (DateTime)value;
                }
            }

            [UserScopedSetting()]
            [DefaultSettingValue("true")]
            public bool NeedsUpdating
            {
                get
                {
                    return ((bool)this["NeedsUpdating"]); ;
                }
                set
                {
                    this["NeedsUpdating"] = (bool)value;
                }
            }
    ....

    I create the object as follows

    ApplicationSettings  AppSettings = new ApplicationSettings();

    and update the application settings as follows

     /// If Upgrade is needed then upgrade settings
     if (AppSettings.NeedsUpdating)
     {
            AppSettings.Upgrade();
            AppSettings.NeedsUpdating = false;
            AppSettings.Save();
            AppSettings = new ApplicationSettings();
     }

    I am not sure what else piece of code do you need to see but please let me know.

    The only other thing that might be related is that in this version I had change before making changes the path where the c# project was saved (D:\Project\MyApp\ --> D:\Version.1.xx\MyApp).

    But when I was troubleshooting I revert back to the original folder and even tried to restore the solution from a backup and complied. But even with the restored  version (without the last changes that I originally believe that created the problem) the settings path was still changing.

    Regards


    Tuesday, January 6, 2015 5:57 PM
  • Hello phanospa,

    Thanks for sharing these information, we are trying to reproduce this issue and as soon as we get any result, we will post back to this forum.

    Update:

    >> The only other thing that might be related is that in this version I had change before making changes the path where the c# project was saved (D:\Project\MyApp\ --> D:\Version.1.xx\MyApp).

    It seems that you changed the executable application path, then it should be that the Evidence Hash is changed, because this values is affected by two things, for a details, please check this link,

    1.StrongName

    2.URL: If neither of these is available, use the .exe path.

    >> But when I was troubleshooting I revert back to the original folder and even tried to restore the…

    For this scenario, I do not reproduce it successfully, when I dropped my .exe back to its original place, it read the setting I saved before.

    After searching more, there is a similar issue and a workaround it to make the stored place to be an absolute path. Or open your config file from specific location using ConfigurationManager.OpenExeConfiguration method as suggested below the workaround in the link I provided.

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    • Edited by Fred Bao Thursday, January 8, 2015 7:40 AM
    Wednesday, January 7, 2015 7:54 AM
  • Hi Fred and thanks for the lengthy respond. Please note that I did not change the path of the executable

    "It seems that you changed the executable application path, then it should be that the Evidence Hash is changed, because this values is affected by two things, for a details...,"

    I only change (temporarily) the path of the developing directory.

    Anyway I have continue and create my own SettingsProvider and set up my own path for settings. It took me a while since I had to make changes in both my settings and my application but I think that eventually I have fix all the bugs that resulted from the change.

    I will ask from my users to manually set their settings again after upgrading to the new version of my software. I know it is not perfect but at least I do not have to worry that the path will again change in the future since now I am setting it explicitly. I wished that there was a way to change the settings path in the default settings provider.

    Thanks for the help.

    • Marked as answer by Fred Bao Friday, January 16, 2015 4:43 AM
    Monday, January 12, 2015 8:29 PM