none
Settings Always Default RRS feed

  • Question

  • My WPF app has 4 settings that are all are Specialized.StringCollection. One of those settings always returns the default when I start the program debugging. The other 4 settings are very similar, some even reading the exact same type of data.

    I can see the saved strings in the user.config but they're not getting read, I'm only getting the default. The major difference in the settings that work and the one that doesn't is the size of the one that doesn't, it's huge, 8000+ strings. Does anyone know what might be causing this?

    Does anyone know what might be causing this? Is there a limit in the size of the collection to the settings?

    Thanks
    Ken

    Friday, January 24, 2020 3:48 AM

All replies

  • It does appear to be the size of the data I'm saving. Given that 112 strings worked but 113 did not I'd say it's an overall size thing and not a number of strings thing.

    I know this really needs to be in a database instead of settings but I can't do that at the moment for reasons I won't bore you with. I guess an old fashion text file will have to do for now.

    After a fair amount of searching I was unable to find any specifications on limitation for the setting data. If anyone knows of a place this might be, I'd appreciate the heads up.

    I also find it curious that I can SAVE that size setting but can't READ that size setting, and there were no errors thrown when trying to "read" the settings. Which makes me think I have some setting wrong someplace. Again, any insight would be appreciated.

    Thanks for reading,
    Ken

    Friday, January 24, 2020 2:01 PM
  • Hi,

    How did you get the data in the config file?

    Properties.Settings.Default.Properties["Name"].DefaultValue

    You can try it with the following code:

    Properties.Settings.Default.Name

    Best Regards,

    Alex


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, January 27, 2020 2:55 AM
    Moderator
  • I'm not sure what you're asking. I set the default is VisualStudio project properties menu:

    Had it set to System.Collections.Specialized.StringCollection, User then clicked the button at the right of the "Value" field and typed in the default.

    In the code I declared a Specialized.StringCollection and used the .Add method to add a bunch of strings then used My.Settings.[SettingsName]=[CollectionName], then My.Settings.Save.

    As I say, this wrote ALL the 8000+ strings to the config file, but I then couldn't read them again, was only getting the default.

    Thanks for replying,
    Ken

    Monday, January 27, 2020 3:07 AM
  • Hi,

    What is your code for getting value from the user.config file?

    Best Regards,

    Alex


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Saturday, February 15, 2020 6:42 AM
    Moderator
  • Hi Alex,

    I was dimming a Specialized.StringCollection and simply assigning it to the setting.

    Dim SettFldrs As New Specialized.StringCollection
    SettFldrs = My.Settings.SetsAndFontsPaths

    Thanks!
    Ken


    • Edited by KenKrugh Monday, February 17, 2020 2:05 AM
    Monday, February 17, 2020 2:05 AM