Preserving My.Settings between product versions

D

David Cartwright

Hi all,

Apologies if this is a FAQ - I've searched all the groups I can think of,
though.

I've written a VB.NET application and an associated Installer project in
Visual Studio 2005. My.Settings works just great, but the problem is that
when I produce a new version of the application, the My.Settings
user-related settings are lost - presumably because they're saved in the
version-specific application data directory and so when a new version number
arrives, the settings file reverts to the default (blank) values.

Is there a straightforward way of making the system "remember" the settings
when the version number increases?

Many thanks in anticipation,

David C
 
K

Kevin Yu [MSFT]

Hi David,

To reflect a most recent installation of the application, we can use
My.Settings.Upgrade method. It will search for the user.config file in the
most recent version of user profile, and copy it the current version
folder. Also, you have to make sure this method is only called once in
your app's first run.

For more information, please check the following link:

http://msdn2.microsoft.com/en-us/library/system.configuration.applicationset
tingsbase.upgrade.aspx

If anything is unclear, please feel free to let me know.

Kevin Yu
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================

(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
K

Kevin Yu [MSFT]

Hi David,

I'd like to know if this issue has been resolved yet. Is there anything
that I can help. I'm still monitoring on it. If you have any questions,
please feel free to post them in the community.

Kevin Yu
Microsoft Online Community Support
==================================================

(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
D

David Cartwright

Kevin Yu said:
I'd like to know if this issue has been resolved yet. Is there anything
that I can help. I'm still monitoring on it. If you have any questions,
please feel free to post them in the community.

Hi Kevin,

Sorry, been away. Yes, that worked a treat thanks. I've just added a boolean
to My.Settings, with default value False, and then in the .Load handler for
the application, chucked in:

IF NOT My.Settings.lUpgraded
My.Settings.Upgrade()
My.Settings.lUpgraded = 1
END IF

Works like a charm - many thanks.

David C
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top