ClickOnce settings disappear

G

Guest

I have deployed my application with ClickOnce, and it works fine.

There are a couple of user settings that the user is allowed to change
through a settings form. Also works fine.

BUT, when I did the most recent deploy all user settings were erased and set
back to their default values. NOT FINE!

I quote from the blog on: http://blogs.msdn.com/rprabhu/articles/433979.aspx

"Q: Okay, but how do I know when to call Upgrade?
A: Good question. In Clickonce, when you install a new version of your
application, ApplicationSettingsBase will detect it and automatically upgrade
settings for you at the point settings are loaded. In non-Clickonce cases,
there is no automatic upgrade - you have to call Upgrade yourself. ....."

So, normally the sepcified user settings should be upgraded automatically,
and I am pretty sure I got that behaviour before.


What can I possible have done?
How can I get it back?
 
J

Jeffrey Tan[MSFT]

Hi jaklithn,

Thanks for your post.

I am not sure I understand your problem very well. I have created a sample
VB2005 project, setting an entry in the settings designer like below:
"test1"--"version1"
I used code below:
My.settings.test1="changed text"
After publishing, it works well.

Then I changed the settings to:
"test1"--"version2"
Code changes below:
Me.Text=My.settings.test1

Then I re-published it. By clicking the clickonce link, I will get the
text: "changed text". So clickonce has called
ApplicationSettingsBase.Upgrade() for us, which retrieves settings from the
previous version that match the current version of the class and store them
out in the current version's user.config file.

Does this meet your need?

If I misunderstand you, please feel free to tell me, thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
J

Jakob Lithner

You understand me correct, and this is the behaviour I want.
But on the last line after upgrade I receive "version2" ......
What can possible have gone wrong?
I have been changing a lot of code because of namespace changes.
I wanted to get rid of namespace specifiers in code and set the Assembly
Root Namespace instead.
But that triggered a lot of changes everywhere, including the app.config and
settings.vb so I am afraid I might have changed something I shouldn't .....

/Jakob
 
J

Jeffrey Tan[MSFT]

Hi Jakob,

Thanks for your feedback.

Have you checked "Applications should check for updates" "before
application startup" in "Updates..." button in Publish tabpage? Also, I
think the simplest workaround for this is explicitly calling
ApplicationSettingsBase.Upgrade() before your config code executing. Does
this meet your need?

Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
G

Guest

I have all the time had the option "Applications should check for updates"
checked.

On your advice I now call My.Settings.Upgrade, before all code is executed.
It does work, but I feel a bit uneasy doing so.
Is there no downside of calling the upgrade method every time the
application is launched?
Can I detect the version switch and only call the upgrade when it is needed?
 
J

Jeffrey Tan[MSFT]

Hi jaklithn,

Thanks for your feedback.

I think you just want to achieve the same effect as the default ClickOnce
behavior, which calls Upgrade method internally for us. So I do not think
calling Upgrade has any side effect.

Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
G

Guest

Believe me or not, bit on the last two upgrades I published it still didn't
work!
My users are a bit frustrated beacuse the missing setting is the key that I
use to give them Write permissions in the application, and they are a bit
tired of entering the key again every time I do a minor upgrade .....

I soon give up on using the UserSettings file and stick to old Registry
settings!
 
J

Jeffrey Tan[MSFT]

Hi jaklithn,

Thanks for your feedback.

Yes, I see your concern. However, because currently, we can not reproduce
this problem, it may take some long time to troubleshoot out the root
cause. Also, I feel strange that explicitly calling to Upgrade() method
also does not work. Because of your urgence, I think you may stay with
other workaround you found. Thanks for your understanding.

Anyway, if you need further help, please feel free to post. Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 

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