Results 1 to 8 of 8

Thread: [RESOLVED] application settings

  1. #1

    Thread Starter
    coder. Lord Orwell's Avatar
    Join Date
    Feb 2001
    Location
    Elberfeld, IN
    Posts
    7,628

    Resolved [RESOLVED] application settings

    evidently i didn't know what i was doing. I am working on a simple game and wanted to save the high score in application settings. Research upon failure has shown that user is read/write but the program doesn't store it between runs. What am i missing?
    My light show youtube page (it's made the news) www.youtube.com/@lightsofelberfeld
    Contact me on the socials www.facebook.com/lordorwell

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: application settings

    Quote Originally Posted by Lord Orwell View Post
    Research upon failure has shown that user is read/write but the program doesn't store it between runs.
    Yes it does, which is the whole point. User-scoped settings have their default values stored in the app config file and their current values stored in a user config file stored under each user's personal folder. If you open the settings page of the project properties and click the Synchronize button, that will prompt you to delete any user config file(s) that have been created while debugging so you will use the default value again on the next run. Try it and see if there is a file to delete.

    You should probably tell us exactly what you're doing and exactly what happens.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    coder. Lord Orwell's Avatar
    Join Date
    Feb 2001
    Location
    Elberfeld, IN
    Posts
    7,628

    Re: application settings

    i actually have the entire project uploaded here:
    http://www.vbforums.com/showthread.php?t=524940
    I browsed the my.settings properties and actually solved this one myself. I needed to call my.settings.save which i was not aware existed since this is my first attempt at using the settings.
    Thanks for your info, it led me in the right direction.
    My light show youtube page (it's made the news) www.youtube.com/@lightsofelberfeld
    Contact me on the socials www.facebook.com/lordorwell

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: application settings

    Quote Originally Posted by Lord Orwell View Post
    I needed to call my.settings.save
    In theory, that's not the case. By default, Save is called implicitly when the application shuts down. There's a check box in the project properties to change that behaviour. You should make sure that that box is checked. If it is then you shouldn't need to call Save yourself. If you do, that suggests to me that your application is not shutting down correctly. An unhandled exception would cause that, as too would stopping the debugger directly rather than exiting the app normally.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5

    Thread Starter
    coder. Lord Orwell's Avatar
    Join Date
    Feb 2001
    Location
    Elberfeld, IN
    Posts
    7,628

    Re: application settings

    Quote Originally Posted by jmcilhinney View Post
    In theory, that's not the case. By default, Save is called implicitly when the application shuts down. There's a check box in the project properties to change that behaviour. You should make sure that that box is checked. If it is then you shouldn't need to call Save yourself. If you do, that suggests to me that your application is not shutting down correctly. An unhandled exception would cause that, as too would stopping the debugger directly rather than exiting the app normally.
    i was doing a lot of improper shutting down. However implicitly saving it actually is more of what i wanted anyway as i wanted it saved immediately.

    I was unable to find the checkbox.
    My light show youtube page (it's made the news) www.youtube.com/@lightsofelberfeld
    Contact me on the socials www.facebook.com/lordorwell

  6. #6
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: application settings

    Quote Originally Posted by Lord Orwell View Post
    However implicitly saving it actually is more of what i wanted anyway as i wanted it saved immediately.
    You mean "explicitly".
    Quote Originally Posted by Lord Orwell View Post
    I was unable to find the checkbox.
    Really? How hard did you look? It's on the Application, i.e. first, page of the project properties and it's caption is "Save My.Settings on Shutdown".
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  7. #7

    Thread Starter
    coder. Lord Orwell's Avatar
    Join Date
    Feb 2001
    Location
    Elberfeld, IN
    Posts
    7,628

    Re: [RESOLVED] application settings

    ok i found it. It was checked. So i don't know what the issue was, except that i almost always was shutting it down by closing it in the ide.
    My light show youtube page (it's made the news) www.youtube.com/@lightsofelberfeld
    Contact me on the socials www.facebook.com/lordorwell

  8. #8
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [RESOLVED] application settings

    Quote Originally Posted by Lord Orwell View Post
    ok i found it. It was checked. So i don't know what the issue was, except that i almost always was shutting it down by closing it in the ide.
    That would be the issue then. If you want to satisfy your curiosity, check the box and don't call Save, then exit the application normally. You should find that the setting(s) is persisted.

    The only time that saving explicitly would be advantageous is if the OS shuts down without warning, e.g. power failure. Even an unhandled exception shouldn't be an issue because you should be handling the UnhandledException event, so the app will still shut down normally and settings will be saved.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width