Click here to Skip to main content
15,896,430 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am attempting to use the My.Settings for the first time. If i "Synchronize" the settings and then run the app, the default settings are there.

If i close the app and run it again all the settings are gone. Any ideas on what could be the problem? (i am running the app in the IDE if that matters)


OH WOW! What a n00b :( Big time copy/paste error on my part. I have 2 settings that have 1 letter different between them. It was saving the value from Abool into BBool instead of Abool into Abool. SO sorry for wasting your time but your answers did ultimately fix the issue since i put msgbox everywhere to track where the value changed :P
Posted
Updated 16-Jan-10 10:57am
v2

If you aren't changing the settings, what is there to persist? I'm still not quite sure what your problem is. If I create a setting called "MySetting" that is a string and has user scope with the value of "DefaultValue", the following code will display "DefaultValue" the first time I run the application and "Changed" the second time I run it:
VB.NET
Public Class Form1
    Private Sub Form1_Load(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles MyBase.Load
        MsgBox(My.Settings.MySetting)
        My.Settings.MySetting = "Changed"
        My.Settings.Save()
    End Sub
End Class
 
Share this answer
 
So, your problem is that you are trying to update your settings in code, but the next time you run your application those changes are not there (they are reverted to the default values)?

What code are you using to "Synchronize" the settings (you should be using the "Save" method)? Is the scope of the settings "User" or "Application"? I think application scope settings do not get saved (could be wrong about that), although I don't think you can assign to them anyway (should produce a compile error).
 
Share this answer
 
The settings are set to User scope. To reset the settings i am using the Synchronize button in the IDE. I am just trying to have the settings stay between app runs. At this point i have no code to modify the settings. Do the settings persist between runs while using the IDE?
 
Share this answer
 
I have many boolean settings which are defaulted to true. When i run the app they are true. If i close the app and re-run it, they are now false.
 
Share this answer
 
Ok, looks like it's a problem with the code in my Preferences screen but not sure what. If i don't open it, the values stay correct, if i do open (without changing any settings) they get messed up.

Will performing My.Settings.Save on a form that isn't the main one cause this problem?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900