Re: My.Settings.Upgrade doesn't upgrade?
- From: hongyes@xxxxxxxxxxxxxxxxxxxx ("Hongye Sun [MSFT]")
- Date: Mon, 17 Nov 2008 10:23:04 GMT
Hi Bob,
Thanks for your post.
This issue is probably caused by "Each new release of my app is installed
into a different folder". I will explain it in detail:
1. How does My.Settings.Upgrade() determine a previous version of the user
settings
In My.Settings, it delegates the upgrade job to LocalFileSettingsProvider
(http://msdn.microsoft.com/en-us/library/system.configuration.localfilesetti
ngsprovider.aspx), which has been specified in
My.Settings.Providers("LocalFileSettingsProvider").
Within LocalFileSettingsProvider, it follows the logic below to find
previous version typically. In order to explain it more understandable, I
will use one example that you provided.
My Profile
Application Data
My Company
MyApplication.exe_Url_gibberish
1.0.0.0
1.1.0.0
We suppose that our application is running as 1.1.0.0 version.
When upgrading:
a. LocalFileSettingsProvider will look for current application's user
config path from AppDomain.CurrentDomain.Evidence. (I will explain it later)
b. The found path looks like "%AppData%/My
Company/MyApplication/MyApplication.exe_Url_gibberish/1.1.0.0/"
c. It goes up to its parent folder "%AppData%/My
Company/MyApplication/MyApplication.exe_Url_gibberish/" and go through all
its subfolders.
d. It finds the biggest version number which is less than 1.1.0.0 and find
the user.config file under that version. (Here the previous version is
1.0.0.0)
e. It merges all the settings from previous version into current one.
2. How is application config path determined?
a. There is an internal class named "ClientConfigPath" who does this
determination.
b. It gets host information by calling
"AppDomain.CurrentDomain.Evidence.GetHostEnumerator()"
c. If the application is strong named, it uses the strong named public key
and assembly name to build hash code and the set the folder name as
"MyApplication.exe_StrongName_xxxxxxxxxxxxx", where "xxxxxxxxxxxxx" stands
for hash code.
d. If the application is not strong named, it will use its evidence URL
(http://msdn.microsoft.com/en-us/library/system.security.policy.url.aspx)
which usually is the application install path, to construct a hash code.
The folder name looks like "MyApplication.exe_Url_gibberish".
So the conclusion is that when the exe assembly is strong named, the folder
name depends on its public key. Otherwise, it depends on the application
install path.
* Solution *
After knowing how My.Settings.Upgrade() works, we can find that making exe
assembly as strong named assembly is one solution to the this problem.
Please have a try of it and let me know if it works for you. Thanks.
Regards,
Hongye Sun (hongyes@xxxxxxxxxxxxxxxxxxxx, remove 'online.')
Microsoft Online Community Support
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msdnmg@xxxxxxxxxxxxxx
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.
Note: MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 2 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. 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/en-us/subscriptions/aa948874.aspx
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
.
- Follow-Ups:
- Re: My.Settings.Upgrade doesn't upgrade?
- From: Bob Altman
- Re: My.Settings.Upgrade doesn't upgrade?
- References:
- My.Settings.Upgrade doesn't upgrade?
- From: Bob Altman
- Re: My.Settings.Upgrade doesn't upgrade?
- From: Bob Altman
- My.Settings.Upgrade doesn't upgrade?
- Prev by Date: Re: Chinese antique
- Next by Date: DataGridView
- Previous by thread: Re: My.Settings.Upgrade doesn't upgrade?
- Next by thread: Re: My.Settings.Upgrade doesn't upgrade?
- Index(es):
Relevant Pages
|