0

I built an app that is reading / storing appSettings like this:

  Dim _config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None)
  Dim _My_Settings = _config.AppSettings.Settings

  'READING
  tbServerIP.Text = _My_Settings.Item("ServerIP").Value

  'STORING
  _My_Settings.Item("ServerIP").Value = "127.0.0.1"
  _config.Save(ConfigurationSaveMode.Modified)

This worked perfectly until I created an installer and installed the app in program files. Then I got an error when reading one (newest) config key/value. The app.config file is included with the installer and configured to sit alongside the EXE file.

To be sure that that prop value is actually missing I run the following and examined the result - the prop was truly missing.

  MessageBox.Show(String.Join(",", _My_Settings.AllKeys))

So I need to find where those values are stored. But, a strange thing is happening: the app is still storing all other values BUT somewhere else, because, of course, it can't save into program files.

Where appSettings values are stored when the app is installed in program files?

Dejan Dozet
  • 948
  • 10
  • 26
  • Is the `app.config` file included with the installer and configured to sit alongside the EXE file? – JayV May 15 '22 at 20:23
  • @JayV yes and the app is working when run with elevated privileges, my guess is that it is crashing because that one config value is not updated to that location which I can't find and which is in use when I run the app normally. – Dejan Dozet May 15 '22 at 20:29
  • Most likely a permission issue; change your default install location to `%appdata%` or another non-privileged folder where a non-elevated process can write. – Mathieu Guindon May 15 '22 at 20:32
  • @MathieuGuindon I assure you that all other settings get updated somewhere, even when the app is in program files, and I can do what you suggested BUT I want to find out where those values are actually stored in this scenario so this question remains active – Dejan Dozet May 15 '22 at 20:36
  • 1
    Look under `%appdata%\local`, user-scoped settings should be there. (double-check setting scopes!) – Mathieu Guindon May 15 '22 at 20:39
  • Are these setting supposed to be per-user or globally for all users? – Klaus Gütter May 16 '22 at 04:15
  • @KlausGütter the app was built to be distributed and run from a folder, but now I want to create an installer for it without changing its structure – Dejan Dozet May 16 '22 at 08:19

1 Answers1

1

I just did as Mathieu suggested and searched in all folders and found it in the following location:

C:\Users\user\AppData\Local\VirtualStore\Program Files (x86)\company\app

So I deleted appSettings file (which was missing that one prop value) and started the app again. The config file got recreated with all props. Now the next question is why it didn't update when I reinstalled app several times?

OK, found a solution for that. I am actually installing appSetting in that folder too by setting Custom Folder #1 to the following path: [LocalAppDataFolder]VirtualStore\Program Files (x86)[Manufacturer][ProductName]

Dejan Dozet
  • 948
  • 10
  • 26