ClickOnce and UserSettings

2019-04-30 06:06发布

问题:

Ok, I have a ClickOnce app that I'm testing and I ask the user for a couple of pieces of information the first time they use load the app; Customer Id and Name. I then set the Properties so that they'll be saved across sessions. The property is Properties.Settings.Default["Customer ID"] and similar for name.

So I uninstall the application through control panel and reinstall the application but the settings are still there! I go and find all directories for my application and delete out the settings but the application acts like it still has them. I can even step through the debugger and see that they are still there.

How do I get rid of them all? This is very frustrating since it makes it almost impossible to test new data and to debug any first time installs.

Thanks...

回答1:

I believe the user config values are stored in this location:

%APPDATA%\<AppName>\<AppName><AppConfigName_GUID>\<AssemblyVersion>\user.config

Have you checked there?



回答2:

ok, in case anyone has the same problem in the future. I had set the properties in Visual Studio through the Settings.settings editor. I removed them and everything was normal again...



回答3:

In answer to the general problem of removing settings when the program is reinstalled, you could add unique piece of data as well, such as the date of the executable, its checksum, or something similar.

Then check that against the saved data when you program starts. If they don't match, it's a reinstall and you can delete the stored data.