Question Regarding My.Settings

danfloun

Member
Joined
Apr 5, 2010
Messages
23
Programming Experience
Beginner
In my app I've got the main form and an options form.
I click the options button on the main form, it opens and I have one combobox containing websites.

If I change the website in the combobox and close the form, then click the button on the main form to httprequest to the newly selected website, it works!

Hallelujah!

But I thought I would need to reload my.settings on the main form for it to recognise the changes, but apparently not. This would suggest that every time a httprequest is made it queries the my.settings file again!... surely not?

On the options form closing event I simply have;

VB.NET:
my.settings.somevalue = combobox.selecteditem.tostring
my.settings.save()

I did initiate my.settings.reload() on the main form after making configuration changes, but it doesn't seem to need it. Surely my.settings are kept in memory at runtime and should need a reload every time a value is rewritten to the my.settings file?

If that doesn't make sense I apologise.

Cheers
Danny
 
There is no My.Settings file, which is the whole point. My.Settings exists in memory. In your Options form, you set My.Settings.SomeValue, which is a property of an object stored in memory. On your main form, the value of My.Settings.SomeValue is used. You could get rid of that call to Save and it would still work, because the correct value is stored in memory. The contents of My.Settings is automatically saved to the config file at app shutdown, so that it can be loaded into memory again at the next app startup.
 
There is no My.Settings file, which is the whole point. My.Settings exists in memory. In your Options form, you set My.Settings.SomeValue, which is a property of an object stored in memory. On your main form, the value of My.Settings.SomeValue is used. You could get rid of that call to Save and it would still work, because the correct value is stored in memory. The contents of My.Settings is automatically saved to the config file at app shutdown, so that it can be loaded into memory again at the next app startup.

Arr right.
When I said my.settings file I meant the config file, but I didn't realise it auto saved at shutdown.

Thanks
Danny
 
Back
Top