Windows Develop Bookmark and Share   
 index > ClickOnce and Setup & Deployment Projects > ClickOnce overwrites user settings My.Settings VB.NET 2008 on update
 

ClickOnce overwrites user settings My.Settings VB.NET 2008 on update

I am rewritting my application to conform to ms standards. We used to save all settings to registry for user settings, servername, size and locations.... so we are now saving them into My.Settings app.config the only problem is that each time there is an update clickonce will isnstall the newupdate but now all settings are loist and user has to save everything all over again..

I am trying to follow the book here but it seems i keep getting stuck somewhere. registry has worked fine for years but i understand we must move on, but if stuff like this happens then i just wasted a long time converting all code to conform for it to not work...

Please advise in what steps i need to take, or what i am doing wrong I hope i am doing something wrong then this is the way it was written.

I have read many posts online about this same issue and none seem to have a good reply or answer. If there is no fix let me know i can find other technology to do updates.

  • Edited bymoe661 Sunday, August 09, 2009 6:41 PM
  •  
moe661  Sunday, August 09, 2009 8:11 AM

Sorry for the delay. (Working a lot these days.)

Ok, so here's the deal. Application settings can not be overwritten by the user, so when you change them in the project, it does deploy the new version over the old.

If you want to store user-specific settings that can be changed by the user, you need to use user-scoped settings instead. Then after the values are modified (My.Settings.MyFieldName = value), save the settings (My.Settings.Save)

It will save them under the \data folder for the ClickOnce deployment.

Then if you change the values in the project and redeploy, it will still use the ones in the ClickOnce data folder, which you can continue to programmatically modify and save.

What we did (because we wanted more control) was roll our own configuration manager, keeping a list of key/value pairs. If you want to store this kind of information in a different format in a different file, you can create a folder under LocalApplicationData with your company name, and store it there. This is the recommended placement for this kind of data on Windows Vista and above, where security is stronger. To get the base path for this folder:

Dim userFilePath as string = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)

Dim myAppCache = Path.Combine(userFilePath, "mycompany")
If (!Folder.Exists(myAppCache))
Directory.Create(myAppCache)
End If

Here's another article that discusses the same issues: http://blogs.msdn.com/rprabhu/articles/433979.aspx

RobinDotNet


Click here to visit my ClickOnce blog!
RobinDotNet  Monday, August 17, 2009 8:08 AM

If you want to users to be able to acess settings and things stored in isolated storage after you push out a new release you need to:
1. KeepthesameAseembly Version. You can change the File Version but not the Assembly Version.
2. Strong Name sign the executable.

You should also be aware that Settings information is stored under Local Settings and will not persist to a roaming profile.

You can persist items in Isolated Storage if you use:
isFile = IsolatedStorageFile.GetStore(IsolatedStorageScope.Roaming Or IsolatedStorageScope.User Or IsolatedStorageScope.Assembly Or IsolatedStorageScope.Domain, Nothing, Nothing)
That will put IsolatedStorage under Applicatoin Data which is persisted to a roaming profile.

saberman  Sunday, August 09, 2009 11:10 PM
saberman -- I completely disagree with your answer here

moe661 -- I'll come back around in two days and provide a better answer, assuming Microsoft hasn't done so in the meantime.

RobinDotNet

Click here to visit my ClickOnce blog!
RobinDotNet  Monday, August 10, 2009 5:49 AM
saberman -- I completely disagree with your answer here

Do you disagree with what I described as happening or with using the approach or both?
saberman  Friday, August 14, 2009 10:43 PM

Sorry for the delay. (Working a lot these days.)

Ok, so here's the deal. Application settings can not be overwritten by the user, so when you change them in the project, it does deploy the new version over the old.

If you want to store user-specific settings that can be changed by the user, you need to use user-scoped settings instead. Then after the values are modified (My.Settings.MyFieldName = value), save the settings (My.Settings.Save)

It will save them under the \data folder for the ClickOnce deployment.

Then if you change the values in the project and redeploy, it will still use the ones in the ClickOnce data folder, which you can continue to programmatically modify and save.

What we did (because we wanted more control) was roll our own configuration manager, keeping a list of key/value pairs. If you want to store this kind of information in a different format in a different file, you can create a folder under LocalApplicationData with your company name, and store it there. This is the recommended placement for this kind of data on Windows Vista and above, where security is stronger. To get the base path for this folder:

Dim userFilePath as string = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)

Dim myAppCache = Path.Combine(userFilePath, "mycompany")
If (!Folder.Exists(myAppCache))
Directory.Create(myAppCache)
End If

Here's another article that discusses the same issues: http://blogs.msdn.com/rprabhu/articles/433979.aspx

RobinDotNet


Click here to visit my ClickOnce blog!
RobinDotNet  Monday, August 17, 2009 8:08 AM
Saberman,

I don't agree -- it doesn't have anything to do with the assembly version or the file version. You have to be able to change the version in order to deploy updates.

Second, MSFT recommends that extraneous data be stored in LocalApplicationData rather than Isolated Storage.

Thanks,
RobinDotNet
Click here to visit my ClickOnce blog!
RobinDotNet  Monday, August 17, 2009 8:09 AM
I don't agree -- it doesn't have anything to do with the assembly version or the file version. You have to be able to change the version in order to deploy updates.

That is the application or publication version not the assembly or file version. ClickOnce applications do not go into the Global Cache. If You change the publication version a new update gets installed.

Second, MSFT recommends that extraneous data be stored in LocalApplicationData rather than Isolated Storage.

I am confused. Isolated Storage can be under /Local Settings/Application Data/ or under /Application Data/. That is controlled by the roaming attribute.

I also am not sure what you mean by extraneous data.

Local Settings/Application Data/ is fine if you are dealing with end users using a single machine that never clean house. Local Settings includes the user's Temp directory -- it was intended for stuff that did not need to be backed up or recovered. It is also where a ClickOnce application is installed -- again for a single user on a machine they own.

What is Isolated Storage for? Isn't it a place to put data that is created/modified by the user and restricted to a particular application?

If you use Strong Name signing of the executable it will be available to updated versions of the application but not to other applications.If you use the roaming attribute it will be under /Application Data/ instead of /Local Settings/Application Data/ andwill also be persisted (assuming the user's profile is setup to be (or at least look like) a roaming profile when the user logs off.

Please excuse me if I am incorrect on how this process works. I asked for an explanation of the naming conventions and locationsfor the directory structures produced by ClickOnce (and .Net) was told that is proprietary -- a trade secret. So the only way to understand them is to reverse engineer them -- change one thing and see what effect it has. When you have to do that you tend to go up a lot ofdead end paths.
saberman  Wednesday, August 19, 2009 6:49 AM

You can use google to search for other answers

Custom Search

More Threads

• text change colour??
• Click once error
• Embedding Window Form inside IE after installing app using ClickOnce
• How to avoid specifing a "Setup folder URL" value in a web based installer.
• How detect Internet Connection is available or not
• Cannot specify product name with "Use application manifest for trust information" option
• On installing Smart Client app getting System.NullReferenceException
• Can I use the installer on my own computer?
• The application requires that the assembly...be installed in the GAC
• Can a User manual and/or Uninstall links be included with ClickOnce deployments?